Javascript Validation
public static bool valid_address(string inputEmail)
{
Contact Address can have alphabets numbers . , ( ) space only.
string strRegex = @"^[a-zA-Z0-9\.\,\(\)\s]+$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static bool valid_alphabet(string inputEmail)
{
string strRegex = @"^[a-zA-Z0-9\.\,\s]+$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static bool valid_city(string inputEmail)
{
City Name can have alphabets . space only.
string strRegex = @"^[a-zA-Z\.\s]+$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static bool valid_password(string inputEmail)
{
Password must be minimum 6 character and combination of alphabets (A-Z )or(a-z)and numerics(0 to 9)
string strRegex = "(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,10})$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static string filterBadchars(string str)
{
string newchars;
int i;
//string[] badchars = new string[15] { "[script]"," select ", ";", "--", " insert ", " delete ", "sp_", "xp_", "(", ")", " and ", " or ", "union", " drop ", ";" };
string[] badchars = new string[14] { "[/script]", "[script]", "select", ";", "--", "insert", "delete", "sp_", "xp_", " and ", "or", "union", "drop", ";" };
int n = badchars.Length;
newchars = str;
for (i = 0; i [ n; i++)
{
newchars = newchars.Replace(badchars[i], "");
// Response.Write(badchars[i]);
}
return newchars;
}
Enter valid Roll No of minimum 7 characters having first two characters may be digits or alhabets and rest are only digits
^[0-9a-zA-Z]{2}[0-9]{5,9}$
Enter your Rollno only Digits (0-9)
^[0-9]+$
Please enter a valid Date (DD/MM/YYYY)
(0[1-9][12][0-9]3[01])[/ /.](0[1-9]1[012])[/ /.](1920)\d\d
{
Contact Address can have alphabets numbers . , ( ) space only.
string strRegex = @"^[a-zA-Z0-9\.\,\(\)\s]+$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static bool valid_alphabet(string inputEmail)
{
string strRegex = @"^[a-zA-Z0-9\.\,\s]+$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static bool valid_city(string inputEmail)
{
City Name can have alphabets . space only.
string strRegex = @"^[a-zA-Z\.\s]+$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static bool valid_password(string inputEmail)
{
Password must be minimum 6 character and combination of alphabets (A-Z )or(a-z)and numerics(0 to 9)
string strRegex = "(?!^[0-9]*$)(?!^[a-zA-Z]*$)^([a-zA-Z0-9]{6,10})$";
Regex re = new Regex(strRegex);
if (re.IsMatch(inputEmail))
return (true);
else
return (false);
}
public static string filterBadchars(string str)
{
string newchars;
int i;
//string[] badchars = new string[15] { "[script]"," select ", ";", "--", " insert ", " delete ", "sp_", "xp_", "(", ")", " and ", " or ", "union", " drop ", ";" };
string[] badchars = new string[14] { "[/script]", "[script]", "select", ";", "--", "insert", "delete", "sp_", "xp_", " and ", "or", "union", "drop", ";" };
int n = badchars.Length;
newchars = str;
for (i = 0; i [ n; i++)
{
newchars = newchars.Replace(badchars[i], "");
// Response.Write(badchars[i]);
}
return newchars;
}
Enter valid Roll No of minimum 7 characters having first two characters may be digits or alhabets and rest are only digits
^[0-9a-zA-Z]{2}[0-9]{5,9}$
Enter your Rollno only Digits (0-9)
^[0-9]+$
Please enter a valid Date (DD/MM/YYYY)
(0[1-9][12][0-9]3[01])[/ /.](0[1-9]1[012])[/ /.](1920)\d\d
great yar
ReplyDelete