所以,我有这两个表单字段。目前,正如您所看到的,它们都是“必需的”。我正在使用标准validate.js
问题是我想将此更改为不是每个都需要默认,但只有用户必须执行一个;所以基本上或者都应该要求。任何方法的想法?
<label class="filebutton">
<span id="select">Select File</span><span><input name="Text1" type="file" id="upload" required></span>
</label>
<textarea class="form-control" name="Text2" rows="5" id="word_count" placeholder="What would you do with your 25th hour? [100 words max]" required></textarea>
<em>Total word count:</em> <span id="display_count">0</span> <em>words.</em> <em>Words left:</em> <span id="word_left">100</span>
<br>
尝试1。)
function validateForm(){
var value1 = document.getElementById('upload').value;
var value2 = document.getElementById('word_count').value;
if( value1 != "" || value2 != "" ) {
return true;
}
alert("You must enter a value");
return false;
}
尝试2。)
$("#form").validate({
rules: {
text1: {
require_from_group: [1, ".phone-group"]
},
text2: {
require_from_group: [1, ".phone-group"]
}
}
});