Posted: Wed Dec 17, 2008 8:46 pm Post subject: If else javascript
heres what i have:
Code:
function checkForm(frmTemp) {
var error = false;
if (frmTemp.txtAn.value.length<3){
alert("Error: Either you forgot to add a word for an animal or your word is less then 3 words long");
error = true;
}
if(frmTemp.txtRoom.value.lenght<3){
alert("Error: Either you forgot to add a word for a room or your word is less then 3 words long");
error = true;
}
if(frmTemp.txtNme.value.lenght<3){
alert("Error: Either you forgot to add a name or your word is less then 3 words long");
error = true;
}
if(frmTemp.txtFnme.value.lenght<3){
alert("Error: Either you forgot to add a friend's name(1) or the name is less then 3 words long");
error = true;
}
if(frmTemp.txtFnme2.value.lenght<3){
alert("Error: Either you forgot to add a friend's name(2) or the name is less then 3 words long");
error = true;
}
if(frmTemp.txtFnme3.value.lenght<3){
alert("Error: Either you forgot to add a friend's name(3) or the name is less then 3 words long");
error = true;
}
if(frmTemp.txtCol.value.lenght<3){
alert("Error: Either you forgot to add a color or your color is less then 3 words long");
error = true;
}
if(frmTemp.txtFlo.value.lenght<3){
alert("Error: Either you forgot to add a Florida 'Place' or your place is less then 3 words long");
error = true;
}
if(frmTemp.txtNycb.value.lenght<3){
alert("Error: Either you forgot to add a Newyork city building or your building is less then 3 words long");
error = true;
}
return error;
}
But it doent work the way i want it to.
if the person enters the first one 3 or more letters, then the story shows up. can u make it so it checks the whole god damn function?
You have a few typos.. value.lenght? and if you are using firefox, open up the error console (tools->error console) so you can view javascript warning/error messages.
It would be far less annoying to do something like "aString += "error: You forgot name\n"; then in the next error do the same thing, and at the end if there is any error, alert the whole thing. _________________
Mutilated lips give a kiss on the wrist of the worm-like tips of tentacles expanding in my mind
I'm fine accepting only fresh brine you can get another drop of this yeah you wish
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum