jQuery条件字段验证(必须至少填写两个字段中的一个)
我甚至无法测试这在JSFIDLE中是否有效,因为我在尝试提交表单时不断收到错误消息:jQuery条件字段验证(必须至少填写两个字段中的一个),jquery,forms,validation,Jquery,Forms,Validation,我甚至无法测试这在JSFIDLE中是否有效,因为我在尝试提交表单时不断收到错误消息: {"error": "Shell form does not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.ShellForm object at 0x3ff9310>, 'html_name': 'js_lib', 'html_initial_id': u'initial-id_js_lib', '
{"error": "Shell form does not validate{'html_initial_name': u'initial-js_lib', 'form': <mooshell.forms.ShellForm object at 0x3ff9310>, 'html_name': 'js_lib', 'html_initial_id': u'initial-id_js_lib', 'label': u'Js lib', 'field': <django.forms.models.ModelChoiceField object at 0x3ff82d0>, 'help_text': '', 'name': 'js_lib'}{'html_initial_name': u'initial-js_wrap', 'form': <mooshell.forms.ShellForm object at 0x3ff9310>, 'html_name': 'js_wrap', 'html_initial_id': u'initial-id_js_wrap', 'label': u'Js wrap', 'field': <django.forms.fields.TypedChoiceField object at 0x3ff8390>, 'help_text': '', 'name': 'js_wrap'}"}
和html:
<form id="signup" method="post" action="">
<div><label >Name</label>
<input id="custom-105958" name="custom-105958" type="text"></div>
<div><label >Birthday (mm/dd/yy)</label>
<input id="custom-105959" name="custom-105959" type="text"></div>
<div><label >Personal Identification Number (PIN)</label>
<input id="custom-105976" name="custom-105976" type="text"> </div>
<input type="submit" value="Submit" />
</form>
名称
生日(月/日/年)
个人识别码(PIN)
编辑:
function Validate() {
var customfirst = document.getElementById('custom-105959').value;
var customsecond = document.getElementById('custom-105976').value;
if (customfirst == '' && customsecond == ''){
alert('empty');
}
else {
alert('inserted');
}
}
function Validate() {
var customfirst = document.getElementById('custom-105959').value;
var customsecond = document.getElementById('custom-105976').value;
if (customfirst == '' && customsecond == ''){
alert('empty');
}
else {
alert('inserted');
}
}