使用Asp.net中的Javascript进行电子邮件和mobno验证 [英] Email and mobno Validation using Javascript in Asp.net
问题描述
我想在asp.net中使用javascript为Mobno和电子邮件进行验证
< script type =text / javascript>
函数validate(){
var cno,email,Msg;
cno = document.getElementById(txt_Cno)。value;
email = document.getElementById(txt_EmailID)。value;
if(cno ==){
Msg =请仅输入否\ n;
}
if(email ==){
Msg + = Please valid email \\\
;
}
返回提醒(消息);
}
< / script>
试试这个<脚本 类型 = text / javascript >
函数validate()
{
if (document.mobilenumbervalidation.mobileno。 value == ||
isNaN(document.mobilenumbervalidation.mobileno。 value )||
document.mobilenumbervalidation.mobileno。 value .length!= 10 )
{
alert( 请提供123格式的手机号码。);
document.mobilenumbervalidation.mobileno.focus();
return false ;
}
if (document.mobilenumbervalidation.phoneno。 value == ||
isNaN(document.mobilenumbervalidation.phoneno。 value )||
document.mobilenumbervalidation.phoneno。 value .length!= 10 )
{
alert( 请提供格式为123的电话号码。);
document.mobilenumbervalidation.phoneno.focus();
return false ;
}
var email = document.mobilenumbervalidation.email_id。 value ;
atpos = email.indexOf( @);
dotpos = email.lastIndexOf( 。);
if (email == || atpos < 1 ||(dotpos - atpos < 2 ))
{
alert( 请输入正确的电子邮件ID);
document.mobilenumbervalidation.email_id.focus();
return false ;
}
return ( true );
}
< / script >
< 表 border = 1 bgcolor = #585858 width = 20% align = center >
< tr >
< < span class =code-leadattribute> td > MobileNo < / td >
< < span class =code-leadattribute> td > < 输入 type = text name = mobileno id = mobileno size = < span class =code-keyword> 30 > < / td >
< < span class =code-leadattribute> / tr >
< tr >
< td > 电话号码< / td >
< td > < 输入 类型 = text 名称 = phoneno id = phoneno size = 30 > < / td >
< / tr >
< tr >
< td > Email_id < < span class =code-leadattribute> / td >
< td > < input type = text name = email_id id = email_id size = 30 > < / td >
< / tr >
I want to give the validation using javascript in asp.net for Mobno and Email
<script type="text/javascript">
function validate() {
var cno, email,Msg;
cno = document.getElementById("txt_Cno").value;
email = document.getElementById("txt_EmailID").value;
if (cno == "") {
Msg = Please Enter only No \n;
}
if (email == ) {
Msg +=Please valid Email \n;
}
return alert(Msg);
}
</script>
try this<script type="text/javascript"> function validate() { if( document.mobilenumbervalidation.mobileno.value == "" || isNaN( document.mobilenumbervalidation.mobileno.value) || document.mobilenumbervalidation.mobileno.value.length != 10 ) { alert( "Please provide a Mobile No in the format 123." ); document.mobilenumbervalidation.mobileno.focus() ; return false; } if( document.mobilenumbervalidation.phoneno.value == "" || isNaN( document.mobilenumbervalidation.phoneno.value) || document.mobilenumbervalidation.phoneno.value.length != 10 ) { alert( "Please provide a Phone No in the format 123." ); document.mobilenumbervalidation.phoneno.focus() ; return false; } var email = document.mobilenumbervalidation.email_id.value; atpos = email.indexOf("@"); dotpos = email.lastIndexOf("."); if (email == "" || atpos < 1 || ( dotpos - atpos < 2 )) { alert("Please enter correct email ID"); document.mobilenumbervalidation.email_id.focus() ; return false; } return( true ); } </script>
<table border="1" bgcolor="#585858" width="20%" align="center"> <tr> <td>MobileNo</td> <td><input type="text" name="mobileno" id="mobileno" size="30"></td> </tr> <tr> <td>Phone No</td> <td><input type="text" name="phoneno" id="phoneno" size="30"></td> </tr> <tr> <td>Email_id</td> <td><input type="text" name="email_id" id="email_id" size="30"></td> </tr>
这篇关于使用Asp.net中的Javascript进行电子邮件和mobno验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!