我需要使用bootstrap验证电子邮件ID我尝试了很多方法,但它没有验证。
<label class=".col-xs-12 .col-sm-6 .col-lg-8" style="margin-left:-1%; margin-right:10%">Email</label>
<input name="Email" class="for" id="email" placeholder="EMail ID" required/>
答案 0 :(得分:0)
<label class=".col-xs-12 .col-sm-6 .col-lg-8" style="margin-left:-1%; margin-right:10%">Email</label>
<input name="Email" class="for" id="email" placeholder="EMail ID" required onblur=ValidateEmail(this.value)/>
//在脚本部分
function ValidateEmail(mail)
{
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(mail))
{
return (true)
} else {
alert("You have entered an invalid email address!")
return (false)
}
}