Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

null and number validation!!!

Status
Not open for further replies.

tuam1234

Technical User
Feb 6, 2004
52
IE
please help!!

in the code below, if the field is empty the alert message will appear but it completly ignores the isNumeric part. when a character is entered, no alert is shown and it continue to next page.

if ((document.formname.exp.value == "")|| (!isNumeric(document.formname.exp.value)))


{
alert("Please enter a valid card expiry date");
document.formname.exp.focus();
return false
}

Any response is greatly appreciated!!!
 
Are you using VB instead of Javascript???


if ((document.formname.exp.value == "")|| (isNaN(document.formname.exp.value)))

simon

 
thanks for replying simon.. iv changed to "isNaN" but it still doesnt diffrenciate between a number and a character..

any other suggestions???
 

try this:

Code:
ft = document.formname.exp.value 
if((isNaN(ft.value)) || (ft.value == null) || ft.value.length == 0)){
    alert("Please enter a valid card expiry date");
    ft.focus();
    return false
  }


simon
 
Try changing simon's code a little from:

Code:
ft = document.formname.exp.value

To:

Code:
ft = document.formname.exp

*grin* Jeff
 
tanx a mil simon, dat worked perfectly...

tanx to u 2 jeff.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top