https://johnnyreilly.github.io/jQuery.Validation.Unobtrusive.Native/AdvancedDemo/Globalize.html
Last active
March 28, 2022 17:38
-
-
Save Crydust/a1935014e755731611f938ceb783e52c to your computer and use it in GitHub Desktop.
dotnet webapp validation config
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="~/lib/jquery-validate/jquery.validate.min.js"></script> | |
<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script> | |
@if (",".Equals(Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator)) | |
{ | |
<script> | |
// decimal separator comma instead of point | |
jQuery.extend(jQuery.validator.methods, { | |
number: function(value, element) { | |
return this.optional(element) || /^-?\d+(?:,\d+)?$/.test(value); | |
}, | |
min: function(value, element, param) { | |
return this.optional(element) || value.replace(/,/g, '.') >= param; | |
}, | |
max: function(value, element, param) { | |
return this.optional(element) || value.replace(/,/g, '.') <= param; | |
}, | |
range: function(value, element, param) { | |
if (this.optional(element)) { | |
return true; | |
} | |
value = value.replace(/,/g, '.'); | |
return (value >= param[0] && value <= param[1]); | |
} | |
}); | |
</script> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "1.0", | |
"defaultProvider": "cdnjs", | |
"libraries": [ | |
{ | |
"library": "bootstrap@5.1.3", | |
"destination": "wwwroot/lib/bootstrap/" | |
}, | |
{ | |
"library": "jquery@3.6.0", | |
"destination": "wwwroot/lib/jquery/", | |
"files": [ | |
"jquery.min.js", | |
"jquery.js", | |
"jquery.min.map" | |
] | |
}, | |
{ | |
"library": "jquery-validation-unobtrusive@3.2.12", | |
"destination": "wwwroot/lib/jquery-validation-unobtrusive/" | |
}, | |
{ | |
"library": "jquery-validate@1.19.3", | |
"destination": "wwwroot/lib/jquery-validate/" | |
} | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment