0

I have 3 radio groups each having 'yes' and 'no' value. Beside each of those radio groups there are 2 dropdown menus 'colour' and 'shade'.

PROBLEM: When I select yes or no for radio button and nothing for the two drop downs and click submit i get an error 'Please select colour and shade for (USER)'. This is how I want it but when i click ok on this error I get please select attendance for USER2 immediately after. How do i remove this as I only want the first error displayed.

9
  • Just a shot in the dark. Have you tried else if? Commented Mar 14, 2012 at 3:23
  • yes i have didnt work either :( Commented Mar 14, 2012 at 3:30
  • Well, Don seems to have nailed it! Commented Mar 14, 2012 at 3:31
  • 1
    Well, you have two lines in your code starting with " $("input:submit").click(function()". Why not combine these two blocks? That should fix it Commented Mar 14, 2012 at 3:38
  • @AmitBhargava Please see revised code. With that code I am not getting any error if i do not select any radio buttons Commented Mar 14, 2012 at 3:43

1 Answer 1

1

You appear to have 2 blocks running on input:submit.click(). So each time the button is pressed, it is running each block.

Sign up to request clarification or add additional context in comments.

8 Comments

Can you add your HTML and generated Javascript (i.e. without the php blocks) on jsfiddle.net so we can see it? You should be able to move the code from the second block into the validate() function.
Strangely, when I added the jQuery code from your question (I tweaked it a bit to remove the PHP and to declare namesArray) it actually works the way you want it. jsfiddle.net/8CTnD/1
I dont think the problem lies with php as i just removed it and it is still doing it
I don't think so either I just had to replace it with something static. Is this page live on the internet somewhere so we can see it in action instead?
how would I break it so that it does not get passed the first 3 validations if it is triggered?
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.