RegularExpressionAttribute – How to make it not case sensitive for client side validation?

I created this attribute which allows you to specify RegexOptions. EDIT: It also integrates with unobtrusive validation. The client will only obey RegexOptions.Multiline and RegexOptions.IgnoreCase since that is what JavaScript supports. [RegularExpressionWithOptions(@”.+@example\.com”, RegexOptions = RegexOptions.IgnoreCase)] C# public class RegularExpressionWithOptionsAttribute : RegularExpressionAttribute, IClientValidatable { public RegularExpressionWithOptionsAttribute(string pattern) : base(pattern) { } public RegexOptions RegexOptions { get; … Read more

.Net Mvc 3 Trigger (other than submit button) Unobtrusive Validation

$(‘form’).valid() should work. Let’s exemplify. Model: public class MyViewModel { [Required] public string Foo { get; set; } } Controller: public class HomeController : Controller { public ActionResult Index() { return View(new MyViewModel()); } } View: @model MyViewModel <script src=”https://stackoverflow.com/questions/6301492/@Url.Content(“~/Scripts/jquery.validate.js”)” type=”text/javascript”></script> <script src=”https://stackoverflow.com/questions/6301492/@Url.Content(“~/Scripts/jquery.validate.unobtrusive.js”)” type=”text/javascript”></script> @using (Html.BeginForm()) { @Html.LabelFor(x => x.Foo) @Html.EditorFor(x => x.Foo) @Html.ValidationMessageFor(x => … Read more

Why do we need both client side and server side validation? [closed]

Client-side validation just avoids the client from going “but I filled this all in and it didn’t tell me anything!”. It’s not actually mandatory, and in reality, client-side validation is a very new thing (read: 5 years old or less). In practice, all it does is prevent your client (with JS enabled) to know whether … Read more