SitePoint Sponsor |
|
User Tag List
Results 1 to 3 of 3
-
Mar 27, 2003, 15:37 #1
- Join Date
- May 2002
- Posts
- 81
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Form Validation - What am I missing?
Hi,
I've got a form validation function that checks to make sure a form value is 19 characters long:
<SCRIPT LANGAUGE="JavaScript">
function checkrequired(){
if (document.data.card_number.value.length > 19 ||document.data.card_number.value.length < 19)
{
alert("Card Number Must be 19 Characters")
return false
}
}
</script>
Call it using:
<FORM NAME="data" METHOD=POST ACTION="myscript.asp" onSubmit="checkrequired(this)">
The alert box pops up if anything other than 19 characters is entered, you hit OK on the alert box, but you're still taken to myscript.asp?
What am I missing?
Thanks
-
Mar 27, 2003, 15:47 #2
- Join Date
- Jul 2002
- Location
- Dallas, TX
- Posts
- 2,900
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
onSubmit="return checkrequired(this)"
You also don't need the double-condition
if ( document.data.card_number.value.length != 19 )
-
Mar 27, 2003, 15:52 #3
- Join Date
- May 2002
- Posts
- 81
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Originally Posted by beetle
Apparently not.
Thanks
Bookmarks