------------
script language="JavaScript">
function onlyNumbers(evt)
{
var e = event || evt; // for trans-browser compatibility
var charCode = e.which || e.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;
return true;
}
only charactyers:
----------------
function fn_validateNumeric(thi,dec)
{
if (window.event) keycode = window.event.keyCode;
else if (e) keycode = e.which;
else return true;
if (((keycode>=65) && (keycode<=90))||((keycode>=97) && (keycode<=122)))
{
return true;
}
else
{
return false;
}
}
only Email:
----------
function validateEmail ( f ) {
if ( isEmail ( f.email_address.value ) == false )
{
alert ( "Please enter a valid email address." );
f.email_address.select ( );
return false;
}
return true;
}
function isEmail ( string ) {
if ( string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1 )
return true;
else
return false;
}
No comments:
Post a Comment