我想验证此表单,但我无法验证这些单选按钮,请帮忙。并且还希望在某些字段错误时显示警报。/ * 这里是 HTML 代码* /<form id="regForm" action="/action_page.php"> <h1>Register:</h1> <!-- One "tab" for each step in the form: --> <div class="tab">Where do you want to move? *: <p><label class="cont">Local <input type="radio" name='thing' value='local' data-id="local"> <span class="checkmark"></span> </label> <label class="cont">Domestic <input type="radio" name='thing' value='domestic' data-id="domestic"> <span class="checkmark"></span> </label> <label class="cont">International <input type="radio" name='thing' value='international' data-id="international"> <span class="checkmark"></span> </label> </p> </div> <div class="tab">Name: <div id="local" class="none"> <p> <label class="cont">1 BHK Goods <input type="radio" name='size' value='1 bhk'> <span class="checkmark"></span> </label> <label class="cont">2 BHK Goods <input type="radio" name='size' value='2 bhk'> <span class="checkmark"></span> </label> <label class="cont">3 BHK Goods <input type="radio" name='size' value='3 bhk'> <span class="checkmark"></span> </label> <label class="cont">4 BHK/Villa Goods <input type="radio" name='size' value='3 bhk'> <span class="checkmark"></span> </label>
2 回答
白衣染霜花
TA贡献1796条经验 获得超10个赞
function validateEmail(emailField){
var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
if (reg.test(emailField.value) == false)
{
alert('Invalid Email Address');
return false;
}
return true;
}
<p><input type="email" placeholder="From..." oninput="this.className = ''" onblur="validateEmail(this);" name="email" ></p>
添加回答
举报
0/150
提交
取消