• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form does not validated correctly

 
tangara goh
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I've been struggling with coding this form for many days. I hope someone can point out to me what went wrong. If a person leaves a blank, then an error message will appear. However, if I didn't enter anything, 2 similar messages appear, which is what I don't want. I only want error message to appear if it is blank or if the data does not conform to the regular expression. Also, I'm not so how to validate the radio button. please please help me.

Here is my code:-

 
Gregg Bolinger
GenRocket Founder
Ranch Hand
Posts: 15302
6
Chrome IntelliJ IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks to me like a JavaScript issue. Moving to the JavaScript forum...
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no need to do this:


That is just a waste of space and js rendering time.

If you do not want both of the error messages to display, than do not do the second check if the first one fails.

Eric
 
tangara goh
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But it is a requirement. I cannot have blank and I need to have validation rules.

Now, the DOB validation just doesn't work and I am taking it off, leaving the bare necessities.

Please advise and also the reset button. Netbean IDE keeps asking me to define object var.

tks.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
tangara goh wrote:But it is a requirement. I cannot have blank and I need to have validation rules.

I think you'll find that JavaScript does not work the way you believe it does.
 
tangara goh
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a check with my friend. Yes. I just take out one and it will work as I want. Tks.
 
Zhixiong Pan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding the radio validator issue, you can refer to the post of http://www.coderanch.com/t/476954/HTML-JavaScript/Radio-Validator.
 
tangara goh
Ranch Hand
Posts: 126
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic