JQuery Validation 1.9 not working in IE9

Does anyone have problems with siilar. I tried combining jQuery 1.5.2, 1.6.1, 1.7.1, and in Firefox and Chrome everything works fine, but IE9 does not.

She is jQuery code. This is a simple login form, and if the text fields for the username and password are empty, it must perform a mandatory check

in firefox and chrome, if I leave the username and password field blank and press the login button, you can activate the checks and labels. This field must be indicated on the right side of both text fields. In IE, it just bypasses this and goes to the controller.

In IE, I changed the browser mode to IE8, IE7, and it works fine. Just IE9 does not.

<form id="frmLogin" method="post" action=""> @Html.LabelFor(m => m.Email) @Html.TextBoxFor(m => m.Email, new { id = "Email" }) @Html.LabelFor(m => m.Password) @Html.PasswordFor(m => m.Password, new { id = "Password" }) @Html.LabelFor(m => m.RememberMe) @Html.CheckBoxFor(m => m.RememberMe) @Html.AntiForgeryToken() <button type="submit">Continue</button> </form> <script type="text/javascript"> $(document).ready(function () { var email = $('#Email'); var password = $('#Password'); password.val(''); if (email.val() == '') email.focus(); else password.focus(); }); $().ready(function () { $.validator.addMethod('alphaNumeric', function (value) { return /^([a-zA-ZčČšŠžŽćĆđĐ0-9]+)?$/.test(value); }, "@ValidationMessages.AlphaNumeric"); $("#frmLogin").validate({ rules: { Email: { required: true, email: true, minlength: 5, maxlength: 50 }, Password: { required: true, alphaNumeric: true, minlength: 6, maxlength: 20 } } }); }); 

+4
source share
1 answer

Try to install

var email = $ ('# Email');
var password = $ ('# Password');

to

var email = $ ('# Email'). val ();
var password = $ ('# Password'). val ();

Variables cannot convert to jquery objects, but instead look for simple values.

0
source

Source: https://habr.com/ru/post/1397865/


All Articles