validation code for mobile number and phone number
"^([+][9][1]|[9][1]|[0]{0,1})([2]{3})([0-9]{7})$"
var phonestring = /^([+][9][1]|[9][1]|[0]{0,1})([2]{2})([2-9]{8})$/
var mobilestring = /^([+][9][1]|[9][1]|[0]{0,1})([7-9]{1})([0-9]{9})$/
var Url = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$";
var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/
/*-------------------JavaScript Validation---------------------------------------*/
<script type="text/javascript" language="javascript">
function passwordlength() {
var pass = document.getElementById("<% = TextBox2.ClientID %>").value;
if (pass.length < 9) {
Label2.innerText = "Week Pass";
}
else if (pass.length > 9) {//|| (pas.length < 12)
Label2.innerText = "Normal";
}
}
function Validations() {
var username = document.getElementById("<% = TextBox1.ClientID %>").value;
var pass = document.getElementById("<% = TextBox2.ClientID %>").value;
var conpass = document.getElementById("<% = TextBox3.ClientID %>").value;
var phone = document.getElementById("<% = TextBox4.ClientID %>").value;
var email = document.getElementById("<% = TextBox5.ClientID %>").value;
var add = document.getElementById("<% = TextBox6.ClientID %>").value;
var url = document.getElementById("<% = TextBox7.ClientID %>").value;
// || pass=="" || conpass=="" || phone=="" || email=="" || add==""
if (username == "") {
//alert("Check Text Box...");
Label1.innerText = "Username Empty....!!";
return false;
document.form1.TextBox1.focus();
}
else {
Label1.innerText = "";
}
if (pass != conpass) {
//alert("Value Doesn't Match.....! : " + pass + conpass)
Label3.innerText = "Value Doesn't Match.....! : " + pass + conpass;
return false;
}
else {
Label3.innerText = "";
}
var phonenumber = /^([+][9][1]|[9][1]|[0]{0,1})([6-9]{1})([0-9]{9})$/
var pnmtch = phone.match(phonenumber);
if (pnmtch == null) {
//alert("Invalid Num.....!")
Label4.innerText = "Check Phone number....!";
document.getElementById("<% = TextBox4.ClientID %>").value = "+91";
return false;
}
else {
Label4.innerText = "";
}
var emailpart = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var matchArray = email.match(emailpart);
if (matchArray == null) {
alert("Your email address seems incorrect. Please try again.");
document.getElementById("<%=TextBox5.ClientID %>").focus();
Label5.innerText = "Your email address seems incorrect. Please try again.";
return false;
}
else {
Label5.innerText = "";
}
if (add == null) {
Label6.innerText = "Don't Skeep";
return false;
}
else {
Label6.innerText = "";
}
var weburl = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%\?\/.=]+$"
var TempUrl = url.match(weburl);
if (TempUrl == null) {
document.getElementById("<%=TextBox7.ClientID %>").value = "http://";
document.getElementById("<%=TextBox7.ClientID %>").focus();
Label7.innerText = "Check URL....!";
return false;
}
else {
Label7.innerText = "";
}
return true;
}
</script>
"^([+][9][1]|[9][1]|[0]{0,1})([2]{3})([0-9]{7})$"
var phonestring = /^([+][9][1]|[9][1]|[0]{0,1})([2]{2})([2-9]{8})$/
var mobilestring = /^([+][9][1]|[9][1]|[0]{0,1})([7-9]{1})([0-9]{9})$/
var Url = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%&\?\/.=]+$";
var emailPat = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/
/*-------------------JavaScript Validation---------------------------------------*/
<script type="text/javascript" language="javascript">
function passwordlength() {
var pass = document.getElementById("<% = TextBox2.ClientID %>").value;
if (pass.length < 9) {
Label2.innerText = "Week Pass";
}
else if (pass.length > 9) {//|| (pas.length < 12)
Label2.innerText = "Normal";
}
}
function Validations() {
var username = document.getElementById("<% = TextBox1.ClientID %>").value;
var pass = document.getElementById("<% = TextBox2.ClientID %>").value;
var conpass = document.getElementById("<% = TextBox3.ClientID %>").value;
var phone = document.getElementById("<% = TextBox4.ClientID %>").value;
var email = document.getElementById("<% = TextBox5.ClientID %>").value;
var add = document.getElementById("<% = TextBox6.ClientID %>").value;
var url = document.getElementById("<% = TextBox7.ClientID %>").value;
// || pass=="" || conpass=="" || phone=="" || email=="" || add==""
if (username == "") {
//alert("Check Text Box...");
Label1.innerText = "Username Empty....!!";
return false;
document.form1.TextBox1.focus();
}
else {
Label1.innerText = "";
}
if (pass != conpass) {
//alert("Value Doesn't Match.....! : " + pass + conpass)
Label3.innerText = "Value Doesn't Match.....! : " + pass + conpass;
return false;
}
else {
Label3.innerText = "";
}
var phonenumber = /^([+][9][1]|[9][1]|[0]{0,1})([6-9]{1})([0-9]{9})$/
var pnmtch = phone.match(phonenumber);
if (pnmtch == null) {
//alert("Invalid Num.....!")
Label4.innerText = "Check Phone number....!";
document.getElementById("<% = TextBox4.ClientID %>").value = "+91";
return false;
}
else {
Label4.innerText = "";
}
var emailpart = /^(\".*\"|[A-Za-z]\w*)@(\[\d{1,3}(\.\d{1,3}){3}]|[A-Za-z]\w*(\.[A-Za-z]\w*)+)$/;
var matchArray = email.match(emailpart);
if (matchArray == null) {
alert("Your email address seems incorrect. Please try again.");
document.getElementById("<%=TextBox5.ClientID %>").focus();
Label5.innerText = "Your email address seems incorrect. Please try again.";
return false;
}
else {
Label5.innerText = "";
}
if (add == null) {
Label6.innerText = "Don't Skeep";
return false;
}
else {
Label6.innerText = "";
}
var weburl = "^[A-Za-z]+://[A-Za-z0-9-_]+\\.[A-Za-z0-9-_%\?\/.=]+$"
var TempUrl = url.match(weburl);
if (TempUrl == null) {
document.getElementById("<%=TextBox7.ClientID %>").value = "http://";
document.getElementById("<%=TextBox7.ClientID %>").focus();
Label7.innerText = "Check URL....!";
return false;
}
else {
Label7.innerText = "";
}
return true;
}
</script>
No comments:
Post a Comment