1

I am new to jQuery validator.

i am making WordPress site i am using http://bassistance.de/jquery-plugins/jquery-plugin-password-validation/ plugin dor password validation.

jQuery validator not working and not showing any error .

i have been trying a lot not able to work it out.

jsfiddle

$(document).ready(function () {
    $("#upme-registration-form").validate({
        rules: {
            user_login: {
                required: true
            },
            user_email: {
                required: true
            },
            user_pass: {
                password: "#user_pass"
            },
            user_pass_confirm: {
                required: true,
                equalTo: "#user_pass_confirm"
            }
        },
        messages: {
            user_login: {
                required: "Enter a username",
                minlength: jQuery.format("Enter at least {0} characters")
            },
            user_email: {
                required: "Enter a username",
                minlength: jQuery.format("Enter at least {0} characters")
            },
            user_pass_confirm: {
                required: "Repeat your password",
                minlength: jQuery.format("Enter at least {0} characters"),
                equalTo: "Enter the same password as above"
            }
        },
        // the errorPlacement has to take the table layout into account
        errorPlacement: function (error, element) {
            error.prependTo(element.parent().next());
        },
        // specifying a submitHandler prevents the default submit, good for the demo
        submitHandler: function () {
            alert("submitted!");
        },
        // set this class to error-labels to indicate valid fields
        success: function (label) {
            // set   as text for IE
            label.html(" HELLo").addClass("checked");
        }
    });
});

i made this above code with the help of submitHandler and .validate() issue but not able to work

thank you

please help

1 Answer 1

2

There are multiple problems

  1. In the fiddle you have included the validate.password.js before validate.js, it is wrong as validate.password.js depends on validate.js - so you need to include the validate.js first
  2. You are including a very old version of the validate plugin which had a dependency on jQuery browser which was removed in jQuery 1.9 - so either upgrade the library to new version of use jQuery 1.8.3 or use jQuery >= 1.9 with the migration plugin
  3. The error placement function is not proper as the parent is the last item, so try error.appendTo(element.parent()); instead.

Demo: Fiddle

Sign up to request clarification or add additional context in comments.

5 Comments

@user2586839 you have not specified any validation rules in the site
@ArunPJohny I am testing it on my localhost. It's not working .
@ArunPJohny yeah it's validating but not submitting. Please help .
@user2586839, if it's "not submitting", then why did you accept this answer? Did you figure it out? Were you simply mistaken and it's working now? Please update us.
@Sparky I removed the submit and success handler to make it work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.