Hi, I looked through the FAQs but I really don't think I need a loop here, which seemed to be the solutions proposed there. I have never had to write my own javascript but now the boss say I have to so I am trying to start simple.
I have a simple HTML form where each form element has a name. I am able to make the other validations work but not the one on a field called zoneQuantite. It is the number of tickets requested. I want to check that it is not empty and give an alert if it is and then check that the number entered is a number. I'm sure it is simple but I cannot get it to work.
My javascript is this
quantiteText takes it's value from the zoneQuantite on the HTML form.
I tried writing it as an elseif statement but I must not have done it correctly because it didn't work. I know there are errors above but this is the clearest way I have written it to show what I wanted to do.
If it is empty, tell them it is empty and that they must enter a number. Then if it has a value in the field but it is not a number tell them they have not entered a number and they must enter a number, in case you don't read French.
Thanks
I have a simple HTML form where each form element has a name. I am able to make the other validations work but not the one on a field called zoneQuantite. It is the number of tickets requested. I want to check that it is not empty and give an alert if it is and then check that the number entered is a number. I'm sure it is simple but I cannot get it to work.
My javascript is this
Code:
function validateQuantite(quantiteText)
{
if (quantiteText.value.length==0)
{
alert("Le champ est vide, veuillez saisir un numéro");
return(false);
}
else
{
return(true);
}
if (isNaN(quantiteText))
{
alert("Vous n'avez pas saisie un numéro, veuillez saisir un numéro");
return(true);
}
else
{
return(false);
}
}
quantiteText takes it's value from the zoneQuantite on the HTML form.
I tried writing it as an elseif statement but I must not have done it correctly because it didn't work. I know there are errors above but this is the clearest way I have written it to show what I wanted to do.
If it is empty, tell them it is empty and that they must enter a number. Then if it has a value in the field but it is not a number tell them they have not entered a number and they must enter a number, in case you don't read French.
Thanks