Internet is growing Every Seconds :: Industry is growing Every Year

Saturday, January 03, 2004

JavaScript Function num_phone()


Function num_phone()

This Function is used to veryfy whether user enter the number or not using keypress event.

For exaample
< input type=text name=txt_phno onkeypres="num_phone();" >


function num_phone()
{
// nummeric with hybhen and blankspace

if (event.keyCode>47 && event.keyCode <58)
{
return true;
}

if (event.keyCode==32)//blankspace
{
return true;
}

if (event.keyCode==45)
{
return true;
}
if (event.keyCode==45) // - HYPHEN
{
return true;
}

event.keyCode=0;
return false;

}