Welcome to Dream.In.Code
Getting Help is Easy!

Join 132,290 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,226 people online right now. Registration is fast and FREE... Join Now!




Validate number field

 
Reply to this topicStart new topic

Validate number field

DarthSideous
post 1 Oct, 2008 - 06:42 AM
Post #1


New D.I.C Head

*
Joined: 1 Oct, 2008
Posts: 7


My Contributions


I have a 6 digit number field that I would like to verify is in fact a number. Basically it is passing right over it.
No validation and no stopping of the script.....What am I missing? I do have several other tests that work fine in similar format...just not this one.....

Any assistance would be great....Thanks

here is the code:

CODE


<form method="post" name="f1" action="PartSave.asp" onsubmit="return checkscript()" ><b><font size="6" face="Tahoma">


<script type="text/javascript">

//validation routine

function checkscript() {
//check that partNum is actually a number
if (isNaN(f1.partNum.value)){
alert('Please Re-enter 6 numeric digits only!');
return false;
}

return true;
}

</script>

Part No: <input type=text name=partNum><br>

User is offlineProfile CardPM

Go to the top of the page

xerxes333
post 1 Oct, 2008 - 08:30 AM
Post #2


D.I.C Head

Group Icon
Joined: 5 Jul, 2007
Posts: 146



Thanked 7 times

Dream Kudos: 25
My Contributions


I think you need to change
CODE
if (isNaN(f1.partNum.value)){
to
CODE
if (isNaN(document.f1.partNum.value)){


I didn't try it out, but I'm pretty sure that should fix it.
User is offlineProfile CardPM

Go to the top of the page

DarthSideous
post 1 Oct, 2008 - 10:52 AM
Post #3


New D.I.C Head

*
Joined: 1 Oct, 2008
Posts: 7


My Contributions


Thanks, but I had tried that with no change... I also tried just using partNum.value ....unfortunately same result.



QUOTE(xerxes333 @ 1 Oct, 2008 - 09:30 AM) *

I think you need to change
CODE
if (isNaN(f1.partNum.value)){
to
CODE
if (isNaN(document.f1.partNum.value)){


I didn't try it out, but I'm pretty sure that should fix it.

User is offlineProfile CardPM

Go to the top of the page

xerxes333
post 2 Oct, 2008 - 05:03 AM
Post #4


D.I.C Head

Group Icon
Joined: 5 Jul, 2007
Posts: 146



Thanked 7 times

Dream Kudos: 25
My Contributions


Ah you are correct, that does not change anything. I suppose I'm confused as to how you are calling the function.
CODE
<form method="post" name="f1" action="PartSave.asp" onsubmit="return checkscript()" ><b><font size="6" face="Tahoma">
The function is sound (I tested it with a button onclick event) which leads me to believe that its the problem arises from the way you are calling the function. I'll try to look at it some more today if I get the time.
User is offlineProfile CardPM

Go to the top of the page

Fast ReplyReply to this topicStart new topic
Time is now: 11/22/08 01:15AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month