• Post Reply Bookmark Topic Watch Topic
  • New Topic

Drop down validation?  RSS feed

 
Daniel Martos
Ranch Hand
Posts: 105
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't figure out how to validate my state drop down box....please help!!!



 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65763
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Life's too short not to use jQuery:



Also, follow naming conventions and don't start names with a capital letter.

And, I'd choose the empty string as a value rather than "all".

And, it unnecessary (and a poor practice) to repeat the same value for the value attribute as the display content of the option. If they're going to be the same, omit the value attributes to avoid possible transcription errors.

And, why the size of 1? If only one can be selected, leave off the size attribute.
 
Daniel Martos
Ranch Hand
Posts: 105
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:Life's too short not to use jQuery:



Also, follow naming conventions and don't start names with a capital letter.

And, I'd choose the empty string as a value rather than "all".

And, it unnecessary (and a poor practice) to repeat the same value for the value attribute as the display content of the option. If they're going to be the same, omit the value attributes to avoid possible transcription errors.

And, why the size of 1? If only one can be selected, leave off the size attribute.


Bear, Thanks for the help, but when I do that, all it does is clear the data from my other boxes.
 
Daniel Martos
Ranch Hand
Posts: 105
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I tried:
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65763
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That line will not do anything to any control. Something else is at work.

My guess is that what is likely happening is that the form is submitting and the page refreshing.
 
Daniel Martos
Ranch Hand
Posts: 105
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:That line will not do anything to any control. Something else is at work.

My guess is that what is likely happening is that the form is submitting and the page refreshing.


It wasn't before that change.....how do I fix that?
 
Daniel Martos
Ranch Hand
Posts: 105
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65763
130
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Daniel Martos wrote:
It wasn't before that change


Likely a JavaScript error was preventing the form from submitting.

You do have the JavaScript console open in the browser? I know you've been asked to do that before.

how do I fix that?

That greatly depends on what you want to have happen. I assume that if the field validates, you want to submit the form, no?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!