/
function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
{alert(alerttxt);return false}
else {return true}
}
}
function validate_email(field,alerttxt)
{
with (field)
{
apos=value.indexOf("@")
dotpos=value.lastIndexOf(".")
if (apos<1||dotpos-apos<2)
{alert(alerttxt);return false}
else {return true}
}
}
/* International Phone Validator */
// Declaring required variables
var digits = "0123456789";
// non-digit characters which are allowed in phone numbers
var phoneNumberDelimiters = "()- ";
// characters which are allowed in international phone numbers
// (a leading + is OK)
var validWorldPhoneChars = phoneNumberDelimiters + "+";
// Minimum no of digits in an international phone no.
var minDigitsInIPhoneNumber = 10;
function isInteger(s)
{ var i;
for (i = 0; i < s.length; i++)
{
// Check that current character is number.
var c = s.charAt(i);
if (((c < "0") || (c > "9"))) return false;
}
// All characters are numbers.
return true;
}
function stripCharsInBag(s, bag)
{ var i;
var returnString = "";
// Search through string's characters one by one.
// If character is not in bag, append to returnString.
for (i = 0; i < s.length; i++)
{
// Check that current character isn't whitespace.
var c = s.charAt(i);
if (bag.indexOf(c) == -1) returnString += c;
}
return returnString;
}
function checkInternationalPhone(strPhone){
s=stripCharsInBag(strPhone,validWorldPhoneChars);
return (isInteger(s) && s.length >= minDigitsInIPhoneNumber);
}
////////////////////////////////
function validate(thisform)
{
with (thisform)
{
if (validate_required(name,"Please Enter Your Name!")==false)
{name.focus();return false}
else if (validate_required(email,"Please Enter Your Email!")==false)
{email.focus();return false}
else if (validate_email(email,"Invalid Email Address!")==false)
{email.focus();return false}
else if (validate_required(phone,"Please Enter Your Phone Number")==false)
{phone.focus();return false}
else if (checkInternationalPhone(phone.value)==false){
alert("Please Enter a Valid Phone Number")
phone.value=""
phone.focus()
return false
}
else if (validate_required(request,"Please Enter Your Request")==false)
{request.focus();return false}
}
}
In form:-
OnSubmit / OnClick validate(this);
First, I have part of the core team which build and launched rechargeitnow.com (1st Online Recharge site in India) from scratch in 2008-2010. Additionally, I managed 15 projects and 25 technology people for HT Digital in 2014-2017. Finally, I managed 50 technology people, 360 websites, 130 apps for Bharat Matrimony in 2017-2019. I am expert in cost-effective technology implementation and people management.
Showing posts with label जावास्क्रिप्ट ईमेल वलिदटर. Show all posts
Showing posts with label जावास्क्रिप्ट ईमेल वलिदटर. Show all posts
Tuesday, November 20, 2007
Subscribe to:
Posts (Atom)