Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Javascript Validation Help
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
prolific
Apprentice
Apprentice


Joined: 19 Apr 2002
Posts: 237

PostPosted: Sat May 31, 2003 5:28 am    Post subject: Javascript Validation Help Reply with quote

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
View user's profile Send private message
redhatJunkie
n00b
n00b


Joined: 19 Apr 2003
Posts: 15
Location: Kanagawa, Japan

PostPosted: Sat May 31, 2003 11:09 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
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