A
Abhishek
Hi this is my another validator in javascript to validate the Phone
Number
<script language='javascript'>
function funcCheckPhoneNumber(ctrtxtMobile,e){
if(window.event){
var strkeyIE = e.keyCode
if(((strkeyIE >= 48) && (strkeyIE <= 57 )) || (strkeyIE >= 40) &&
(strkeyIE <= 41 ) || (strkeyIE == 32) || (strkeyIE == 46)||(strkeyIE
== 45) ){}
else{
return false;}}
else{
var strkeyCode = e.keyCode
var strCharCode = e.charCode
if(((strCharCode >= 48) && (strCharCode <= 57 )) || ((strCharCode
(strkeyCode == 46)||(strCharCode==46)||(strkeyCode==8 ) || (strkeyCode
==9 ) ||(strkeyCode==39) || (strkeyCode ==35) || (strkeyCode ==36) ||
(strkeyCode==9)){}
else{
return false;}}
return true;}
function valFuncReg_PhoneNumber(text,reg){
if(text == null || text == '')return true;
if(reg == null || reg =='')return true;
var regex = new RegExp(reg);var value=text;
var res= (regex.exec(text));
if(res==null){
reg =/^\d*$/;
regex = new RegExp(reg);
res= (regex.exec(text));
}
return (res != null && value == res[0]);}
</script>
The above script can be called on "Onkeypress" event of the TextBox as
follows :
"Onkeypress", "javascript:return funcCheckPhoneNumber(this,event);"
Please feel free to give Comments and Suggessions and Bugs also
Number
<script language='javascript'>
function funcCheckPhoneNumber(ctrtxtMobile,e){
if(window.event){
var strkeyIE = e.keyCode
if(((strkeyIE >= 48) && (strkeyIE <= 57 )) || (strkeyIE >= 40) &&
(strkeyIE <= 41 ) || (strkeyIE == 32) || (strkeyIE == 46)||(strkeyIE
== 45) ){}
else{
return false;}}
else{
var strkeyCode = e.keyCode
var strCharCode = e.charCode
if(((strCharCode >= 48) && (strCharCode <= 57 )) || ((strCharCode
(strCharCode==32)|| (strkeyCode==37 )|| (strkeyCode==38) ||= 40) && (strCharCode <= 41 )) || (strCharCode == 45) ||
(strkeyCode == 46)||(strCharCode==46)||(strkeyCode==8 ) || (strkeyCode
==9 ) ||(strkeyCode==39) || (strkeyCode ==35) || (strkeyCode ==36) ||
(strkeyCode==9)){}
else{
return false;}}
return true;}
function valFuncReg_PhoneNumber(text,reg){
if(text == null || text == '')return true;
if(reg == null || reg =='')return true;
var regex = new RegExp(reg);var value=text;
var res= (regex.exec(text));
if(res==null){
reg =/^\d*$/;
regex = new RegExp(reg);
res= (regex.exec(text));
}
return (res != null && value == res[0]);}
</script>
The above script can be called on "Onkeypress" event of the TextBox as
follows :
"Onkeypress", "javascript:return funcCheckPhoneNumber(this,event);"
Please feel free to give Comments and Suggessions and Bugs also