0

您好我正在使用 jquery 进行简单的表单注册验证。唯一的事情是我使用了引导框架。

当我点击注册按钮时,将会发生;

在火虫控制台中显示

[09:35:37.239] Empty string passed to getElementById(). @ http://www.matrimonyteam.com/home/registration

有关更多信息,请访问此网址http://www.matrimonyteam.com/home/registration

function register(){

    var validator = $("#profileRegistrationForm").validate({
        rules: {                            
            firstName: "required",
            lastName: "required",
            email: "required",
            loginPassword: "required",
            mobileNumber: "required",       
            gender: "required",
            birthDate: "required",
            motherTongue: "required"
        },
        errorElement: "span",                               
            messages: {
            firstName: "Enter First Name",
            lastName: "Enter Last Name",
            email: "Enter Valid Email Address",
            loginPassword: "Enter Password",
            mobileNumber: "Enter Mobile Number",        
            gender: "Select Your Gender",
            birthDate: "Select Birth Date",
            motherTongue: "Select Mother Tongue"
            }
    });
    if(validator.form()){ 
         $('form#profileRegistrationForm').attr({action: '/home/saveprofile'});         
         $('form#profileRegistrationForm').submit();
    }   
}

点击事件已注册

 <script type="text/javascript"> 
    $(document).ready(function () {

        $('#register').click(function() {       
            register();
        });     
    </script> 
4

1 回答 1

1

我认为您在删除jquery 1.9 $.browser后使用的是较新版本的 jquery 。

您可以download使用最新版本(当前版本:1.11.1validate plugin来解决问题。或者你可以使用CDN

http://ajax.aspnetcdn.com/ajax/jquery.validate/1.11.1/jquery.validate.js

或从http://bassistance.de/jquery-plugins/jquery-plugin-validation下载

阅读已删除的 jQuery.browser()jQuery Core 1.9 升级指南。

也读这个

于 2013-07-16T04:42:58.120 回答