+ {
+ }
+}
diff --git a/DataAnnotationsExtensions.Web/DataAnnotationsExtensions.Web.csproj b/DataAnnotationsExtensions.Web/DataAnnotationsExtensions.Web.csproj
index 8715815..ca5c555 100644
--- a/DataAnnotationsExtensions.Web/DataAnnotationsExtensions.Web.csproj
+++ b/DataAnnotationsExtensions.Web/DataAnnotationsExtensions.Web.csproj
@@ -61,6 +61,7 @@
Properties\CommonAssemblyInfo.cs
+
@@ -97,6 +98,8 @@
+
+
@@ -201,6 +204,7 @@
+
diff --git a/DataAnnotationsExtensions.Web/Scripts/jquery.validate.additional-methods.js b/DataAnnotationsExtensions.Web/Scripts/jquery.validate.additional-methods.js
new file mode 100644
index 0000000..b4869fd
--- /dev/null
+++ b/DataAnnotationsExtensions.Web/Scripts/jquery.validate.additional-methods.js
@@ -0,0 +1,12 @@
+jQuery.validator.addMethod("greaterThan", function (value, element, param) {
+ var target = $(param).unbind(".validate-greaterThan").bind("change.validate-greaterThan", function () {
+ $(element).valid();
+ });
+ return (Date.parse(value) || parseFloat(value)) > (Date.parse($(param).val()) || parseFloat($(param).val()));
+});
+jQuery.validator.addMethod("greaterThanOrEqualTo", function (value, element, param) {
+ var target = $(param).unbind(".validate-greaterThanOrEqualTo").bind("change.validate-greaterThanOrEqualTo", function () {
+ $(element).valid();
+ });
+ return (Date.parse(value) || parseFloat(value)) >= (Date.parse($(param).val()) || parseFloat($(param).val()));
+});
\ No newline at end of file
diff --git a/DataAnnotationsExtensions.Web/Scripts/jquery.validate.unobtrusive.additional-methods.js b/DataAnnotationsExtensions.Web/Scripts/jquery.validate.unobtrusive.additional-methods.js
new file mode 100644
index 0000000..bcef053
--- /dev/null
+++ b/DataAnnotationsExtensions.Web/Scripts/jquery.validate.unobtrusive.additional-methods.js
@@ -0,0 +1,77 @@
+function baseUnobtrusiveAdapterFunctions() {
+ function getModelPrefix(fieldName) {
+ return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
+ }
+
+ function appendModelPrefix(value, prefix) {
+ if (value.indexOf("*.") === 0) {
+ value = value.replace("*.", prefix);
+ }
+ return value;
+ }
+ function setValidationValues(options, ruleName, value) {
+ options.rules[ruleName] = value;
+ if (options.message) {
+ options.messages[ruleName] = options.message;
+ }
+ }
+ function getElement(options) {
+ var prefix = getModelPrefix(options.element.name),
+ other = options.params.other,
+ fullOtherName = appendModelPrefix(other, prefix),
+ element = $(options.form).find("input[name='" + fullOtherName + "']")[0];
+ return element;
+ }
+}
+
+jQuery.validator.unobtrusive.adapters.add("greaterthan", ["other"], function (options) {
+ function getModelPrefix(fieldName) {
+ return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
+ }
+
+ function appendModelPrefix(value, prefix) {
+ if (value.indexOf("*.") === 0) {
+ value = value.replace("*.", prefix);
+ }
+ return value;
+ }
+ function setValidationValues(options, ruleName, value) {
+ options.rules[ruleName] = value;
+ if (options.message) {
+ options.messages[ruleName] = options.message;
+ }
+ }
+
+ var prefix = getModelPrefix(options.element.name),
+ other = options.params.other,
+ fullOtherName = appendModelPrefix(other, prefix),
+ element = $(options.form).find("input[name='" + fullOtherName + "']")[0];
+
+ setValidationValues(options, "greaterThan", element);
+});
+jQuery.validator.unobtrusive.adapters.add("greaterthanorequalto", ["other"], function (options) {
+ function getModelPrefix(fieldName) {
+ return fieldName.substr(0, fieldName.lastIndexOf(".") + 1);
+ }
+
+ function appendModelPrefix(value, prefix) {
+ if (value.indexOf("*.") === 0) {
+ value = value.replace("*.", prefix);
+ }
+ return value;
+ }
+ function setValidationValues(options, ruleName, value) {
+ options.rules[ruleName] = value;
+ if (options.message) {
+ options.messages[ruleName] = options.message;
+ }
+ }
+
+ var prefix = getModelPrefix(options.element.name),
+ other = options.params.other,
+ fullOtherName = appendModelPrefix(other, prefix),
+ element = $(options.form).find("input[name='" + fullOtherName + "']")[0];
+
+
+ setValidationValues(options, "greaterThanOrEqualTo", element);
+});
diff --git a/DataAnnotationsExtensions.Web/Views/GreaterThan/Create.cshtml b/DataAnnotationsExtensions.Web/Views/GreaterThan/Create.cshtml
new file mode 100644
index 0000000..46a611d
--- /dev/null
+++ b/DataAnnotationsExtensions.Web/Views/GreaterThan/Create.cshtml
@@ -0,0 +1,25 @@
+@model DataAnnotationsExtensions.Core.GreaterThanEntity
+
+@{
+ ViewBag.Title = "Create";
+}
+
+Create
+
+@using (Html.BeginForm()) {
+ @Html.ValidationSummary(true)
+
+}
+
+
+ @Html.ActionLink("Back to demos", "Demos", "Home")
+
+
diff --git a/DataAnnotationsExtensions.Web/Views/GreaterThanOrEqualTo/Create.cshtml b/DataAnnotationsExtensions.Web/Views/GreaterThanOrEqualTo/Create.cshtml
new file mode 100644
index 0000000..d345de6
--- /dev/null
+++ b/DataAnnotationsExtensions.Web/Views/GreaterThanOrEqualTo/Create.cshtml
@@ -0,0 +1,25 @@
+@model DataAnnotationsExtensions.Core.GreaterThanOrEqualToEntity
+
+@{
+ ViewBag.Title = "Create";
+}
+
+Create
+
+@using (Html.BeginForm()) {
+ @Html.ValidationSummary(true)
+
+}
+
+
+ @Html.ActionLink("Back to demos", "Demos", "Home")
+
+
diff --git a/DataAnnotationsExtensions.Web/Views/Shared/_Layout.cshtml b/DataAnnotationsExtensions.Web/Views/Shared/_Layout.cshtml
index 61723eb..8b57286 100644
--- a/DataAnnotationsExtensions.Web/Views/Shared/_Layout.cshtml
+++ b/DataAnnotationsExtensions.Web/Views/Shared/_Layout.cshtml
@@ -71,6 +71,8 @@
+
+