emailid and mobile nuber validation using javascript [Resolved]

Posted by Gow.Net under JavaScript on 9/23/2012 | Points: 10 | Views : 18027 | Status : [Member] | Replies : 3
how to set 10 digit mobile number and email id using java script in asp.net

gowthaman8870226416


Responses

Posted by: Hariinakoti on: 9/23/2012 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Gow.net,
see this code:
for mail id checking:
function validate(form_id,email) {

var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
var address = document.forms[form_id].elements[email].value;
if(reg.test(address) == false) {

alert('Invalid Email Address');
return false;
}
}
after that call this function in button control.

Thanks & Regards
Hari

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/23/2012 [Member] Starter | Points: 25

Up
0
Down
[b]for mobile no:[/b]

<script type="text/javascript">

function ValidateMobNumber(txtMobId) {
var fld = document.getElementById(txtMobId);


if (fld.value == "") {
alert("You didn't enter a phone number.");
fld.value = "";
fld.focus();
return false;
}
else if (isNaN(fld.value)) {
alert("The phone number contains illegal characters.");
fld.value = "";
fld.focus();
return false;
}
else if (!(fld.value.length == 10)) {
alert("The phone number is the wrong length. \nPlease enter 10 digit mobile no.");
fld.value = "";
fld.focus();
return false;
}

}

</script>


Thanks & Regards
Hari

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Hariinakoti on: 9/23/2012 [Member] Starter | Points: 25

Up
0
Down
if u satisfy with my answer.Please select Mark As Answer.

Thanks & Regards
Hari

Gow.Net, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response