Floodster
Technical User
- Jan 28, 2005
- 204
Hi,
First of all I'm no expert at JAVASCRIPT!!!
I have a form that requires 3 input fields to be entered before the form can be submitted to the database. In the database the first 2 fields are set to VARCHAR & the third is set to INT.
I have this below code which validates to make sure an entry has been entered but if someone enters text in the 3rd field it still validates but then I get an error when trying to insert into my database.
How can I implement a check into this existing code to ensure that a number is being entered in the 3rd field??
Thanks.
First of all I'm no expert at JAVASCRIPT!!!
I have a form that requires 3 input fields to be entered before the form can be submitted to the database. In the database the first 2 fields are set to VARCHAR & the third is set to INT.
I have this below code which validates to make sure an entry has been entered but if someone enters text in the 3rd field it still validates but then I get an error when trying to insert into my database.
Code:
function validate(field,alerttxt)
{
with (field)
{
if (value=="")
{alert(alerttxt);return false}
else {return true}
}
}
function validate_member(form1)
{
with (form1)
{
if (validate(txtName,"Name cannot be blank")==false)
{txtName.focus();return false}
if (validate(txtEmail,"Email cannot be blank")==false)
{txtEmail.focus();return false}
if (validate(txtHcap,"Handicap cannot be blank")==false)
{txtHcap.focus();return false}
}
}
How can I implement a check into this existing code to ensure that a number is being entered in the 3rd field??
Thanks.