| View previous topic :: View next topic |
| Author |
Message |
prolific Apprentice

Joined: 19 Apr 2002 Posts: 237
|
Posted: Sat May 31, 2003 5:28 am Post subject: Javascript Validation Help |
|
|
| Code: | <SCRIPT LANGUAGE="JavaScript">
function checkForm(){
theform=document.custinfo
if ((theform.acode.value / theform.acode.value) != 1){
alert("Please enter your acode.")
theform.acode.focus()
return false;
}
if (theform.acode.length!=3){
alert("Please enter your acode.")
theform.acode.focus()
return false;
}
return true;
}
</SCRIPT> |
Hi. This is a java script app that checks a textfield called "acode" to make sure that it is a number[0-9] and that it contains only 3 characters... If i type a bunch of letters it returns with the error message like its supposed to .. However, no matter how many numbers i enter , it doesnt show the error code like its supposed to.. If i dont enter 3 numbers its supposed to show the error message.. But it doesnt do this.. Can anyone help?
Thanks |
|
| Back to top |
|
 |
redhatJunkie n00b


Joined: 19 Apr 2003 Posts: 15 Location: Kanagawa, Japan
|
Posted: Sat May 31, 2003 11:09 am Post subject: |
|
|
Javascript has a way of deciding what type yout variables are for you... try changing
if (theform.acode.length!=3)
to
if ("G" + theform.acode.length!=4)
adding a character to the variable will ensure that it is treater as a string. I hope this works for you, and if it dosn't, you will never find a better Javascript help forum than:
http://www.webxpertz.net/forums/
Good Luck
RHJ |
|
| Back to top |
|
 |
|
|
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
|
|