function validate(){
var MobileNumber = document.getElementById(“MobileNumber”).value;
var MobileNumberRegEx = /^\+27[78][23467][0-9]{7}/;
if (MobileNumberRegEx.test(MobileNumber)) {
return true;
}else{
alert(“Please enter a valid South African mobile phone number\nin the following format: +27820000000″);
return false;
}
}
Validate SA Cell Number with Javascript
14 02 2007Comments : Leave a Comment »
Categories : Javascript, Regular Expressions
isEmail
1 02 2007The following C# function returns true if the supplied inputEmail is a valid email address.
private static bool isEmail(string inputEmail)
{
inputEmail = NulltoString(inputEmail);
string strRegex = @”^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}” +
@”\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\” +
@”.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$”;
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
Comments : Leave a Comment »
Categories : C#, Regular Expressions
isMobile
31 01 2007This function returns true if the string provided is a valid South African mobile phone number in the following format: 27821234567.
private static bool isMobile(string inputMobile)
{
inputMobile = NulltoString(inputMobile);
string strRegex = “(^27[78][2347][0-9]{7})”;
Regex re = new Regex(strRegex);
if (re.IsMatch(inputMobile))
return (true);
else
return (false);
}
Comments : Leave a Comment »
Categories : C#, Regular Expressions
Regular Expression Library
31 01 2007RegExLib.com has a great collection of regular expressions. Developing for South African users, I find this collection particularly usefull.
Comments : Leave a Comment »
Categories : Regular Expressions