0

我有这样的表格:

<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")
4

1 回答 1

1

我将名称从 submit 更改为 go,它开始工作,dyaamn !

<input type="button" name="go" value="go" id="gogogo" onClick="validate_addUser();" >
于 2012-06-19T03:09:01.377 回答