KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
My goal is to validate a user input on the client-side, depending on the users' culture. I have a primitive data-model with the following structure: public class User { public int UserId { get; set; } [Required] [StringLength(20,MinimumLength=3)] public string Name { get; set; } [Required] public double Height { get; set; } } Furthermore, I want to have client-side validation enabled, checking if it is a valid number. Therefore, I've added the following lines in the <head> section of my _Layout.cshtml. <script src="@Url.Content("~/Scripts/jQuery-1.4.2.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> Since I want to have the ability to validate the input in another language formats (in this particular context it's German with the decimal number format of 0,75 whereas in the US it would be 0.75 ), I've added the following lines ( jQuery Globalization PlugIn ) AFTER the previously mentioned jquery.validate.min.js and jquery.validate.unobtrusive.min.js . <script src="@Url.Content("~/Scripts/jquery.glob.js")" type="text/javascript"></script> <script src="@Url.Content("~/Scripts/globinfo/jquery.glob.de-de.js")" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function () { $.culture = jQuery.cultures['de-DE']; $.preferCulture($.culture.name); }); </script> In addition, I've added the following line to the web.config in the system.web
Tags (comma-separated)
Save Edits
Cancel