0

我有一个使用 onClick 功能提交的表单,它运行良好。但是,现在我试图通过检查特定文本区域中是否有任何文本来验证表单,以便表单可以通过调用上述函数来提交。

这是 HTML:(省略了无关的 html)

<textarea name="employee_statement" onblur="checkMaxLengthT(this,'Employee Statement',2000);" class="inputTextareaFu60R employeeStmtInput">test</textarea>
<input name="save" type="button" class="btn6022" value="Save" onClick="checkEmployeeStmtInput();compare3dates(onset_date,report_date,fatal_death_date,'caseUpdateCase.do')">

这是jQuery函数:

checkEmployeeStmtInput(){
    var employeeStmt = $('textarea.employeeStmtInput').val();
        if (employeeStmt == ''){
            alert('You must provide an Employee Statement.');
            return false;
        }
    }

本质上,现在,原始的 onClick 函数永远不会被调用。如果我删除checkEmployeeStmtInput()函数调用,它确实有效。

4

2 回答 2

1

你需要function之前有checkEmployeeStmtInput(),所以它会写成function checkEmployeeStmtInput() {}.

于 2013-06-07T14:59:43.223 回答
0

调用这个函数,这可能会对你有所帮助。

 function validate(){

    if(any textfield=="empty"){
    alert("field is empty");
    return false;
    }
    else{
    return true;
        }
    }
于 2013-06-07T14:44:53.017 回答