jQuery表单提交错误

时间:2012-06-19 02:03:15

标签: jquery

我有一个这样的表格:

<form method="post" action="user_submit.php" id="addUserForm">
        <p>
            <label for="username">Enter Username:*</label>
            <input type="text" name="username" id="username">
        </p>
         <p>
            <label for="firstname">Enter First Name*</label>
            <input type="text" name="firstname" id="firstname">
        </p>

 <input type="hidden" name="addUser" value="1" />
        <p><input type="button" name="submit" value="submit" id="submit_AddUser" onClick="validate_addUser();" ></p>

这是简单的js即时使用

function validate_addUser(){
    if (!$('#username').val())
        alert('Please enter Username');
    else if (!$('#firstname').val())
        alert("Please enter first name");
    else if (!$('#lastname').val())
        alert("Please enter last name");
    else if (!$('#email').val())
        alert("Please enter email address");
    else 
        $('#addUserForm').submit();

}

当我提交表单时,这是我得到的错误

e[h] is not a function
[Break On This Error]   

...{href:function(a){return a.getAttribute("href")

1 个答案:

答案 0 :(得分:1)

我将名称从提交更改为go并开始工作,dyaamn !!

<input type="button" name="go" value="go" id="gogogo" onClick="validate_addUser();" >