我正在尝试使用 jQuery validate 来验证表单并处理表单提交,但似乎无法正确获取语法,并且无法在 API 中找到像我这样的示例。我的代码如下:
$("#beta_form").validate({
rules: {
p_emailaddress: {
required: true,
email :true
}
}
submitHandler : function() {
$.ajax({
type:'POST',
url :'websiteUrlWithService',
data: $('#beta_form').serialize(),
complete: function() {
$('#dialog').jqmHide();
$('#formSubmissionThanks').jqmShow();
}
});
}
});
表单 HTML 如下:
<form class="login_form" id="beta_form" name="beta_form">
<label for="p_name" class="login_label">Name:</label>
<input type="hidden" id="p_enquiry" name="p_enquiry" value="Beta Enquiry" />
<input type="text" id="p_name" name="p_name" class="login_input" value="" />
<br />
<br/>
<label for="emailaddress" class="login_label">Email Address:</label>
<input type="text" id="p_emailaddress" name="p_emailaddress" class="login_input" value="" />
<br />
<br/>
<label for="role" class="login_label">Current Role:</label>
<select size="1" id="p_role" name="p_role">
<option value="1">None Selected</option>
<option value="2">Recruiter</option>
<option value="3">HR Role</option>
<option value="4">Self Employed</option>
</select>
<br/>
<br/>
<label for="terms" class="login_label">Include me in the Beta testing selection?</label>
<input type="checkbox" id="p_terms" name="p_terms" class="boxes login_label"/>
<br />
<br/>
<input type="submit" id="submitbuttonbeta" class="login_submitbutton" value="Submit" />
</form>
当我使用 Firebug 运行它时,它表明我}
在属性列表之后缺少 a,submitHandler
但据我所知,语法是正确的。此错误阻止我的表单完全触发。
有什么建议么?