您好我正在编写一个多步骤表单,并且使用带有<fieldset> </fieldset>
标记的jquery脚本划分不同的表单部分
我的表单验证在该脚本上运行,看起来像这样
$(".next").click(function(){
var erros = 0;
//error checking in the first fieldset
if (fieldsetn == 1) {
//verify name
if ($('input[name="name"]').val().length ===0){
$('input[name="name"]').attr("placeholder","Please enter your name");
$('input[name="name"]').addClass('warning');
erros = 1;
}
else {
$('input[name="name"]').removeClass('warning');
}
//verify surname
if ($('input[name="surname"]').val().length ===0){
$('input[name="surname"]').attr("placeholder","Please enter your surname");
$('input[name="surname"]').addClass('warning');
erros = 1;
}
else {
$('input[name="surname"]').removeClass('warning');
}
但是我在验证选择字段集时遇到了问题 我的选择字段像这样:
<label class="select" name="industry" id="industry">
<select required name="Industry" >
<option value="" selected disabled>Please Select your Industry</option>
<option value="agriculture">Agriculture</option>
<option value="accounting ">Accounting </option>Advertising
<option value="Advertising ">Advertising </option>
<option value="animals">Animal & Pet</option>
如何验证jquery验证代码结构中的select字段,以便必须选择一个选项?提前谢谢