-3

これは私の検証コードです

$('#reg_form').validate({
            onkeyup: false,
            errorClass: 'error',
            validClass: 'valid',
            rules: {
                username: {
                    required: true,
                    minlength: 5,
                    //remote: "checkusername.php"
                },
                password: {
                    required: true,
                    minlength: 5,
                },
                confirm_password: {
                    required: true,
                    minlength: 5,
                    //equalTo: "#password",
                },
                secretQuestion: "required",
                secretAnswer: "required",
                emailId: {
                    required: true, 
                    email: true,
                    remote: "checkemail.php"
                },
                termsConditions: "required",                
            },
            messages:{
                username: {
                    required: "Please enter Username",
                    minlength: "Please enter atleast 5 characters",

                },
                password: {
                    required: "Please provide a password",
                    minlength: "Your password must be at least 5 characters long"
                },
                confirm_password: {
                    required: "Please provide a password",
                    minlength: "Your password must be at least 5 characters long",
                    //equalTo: "Please enter the same password as above" 

                },
                secretQuestion: "Please select your question",
                secretAnswer: "Please enter your secret answer",
                emailId: {
                    required: "Please enter a valid email address",
                    remote: "Email is aleardy is exists! please try with onother",
                    },
                termsConditions: "Please accept our Terms and COnditions"
            },
            highlight: function(element) {
                $(element).closest('div').addClass("f_error");
            },
            unhighlight: function(element) {
                $(element).closest('div').removeClass("f_error");
            },
            errorPlacement: function(error, element) {
                $(element).closest('div').append(error);
            }
        });
4

1 に答える 1

0

jQueryプラグインのページにリモートメソッドの非常に簡単な説明があります。

あなたへの私の提案に従って!メソッドをよりよく理解するには、展開された形式でメソッドを使用してください。

emailId: {
    required: true, 
    email: true,
    remote: {
        url: "checkmail.php", //the url of the page you are querying
        type: "post", //the method you are going to use to send the data
        data: { //the data you are going to send
           email: function() { 
             return $("#email").val(); //send the value of email
           }
        }
    }
},

ただし、コードはそのまま動作するはずです。

于 2012-07-13T06:19:07.103 に答える