0

I am using below code for validation of fields of my Dialog Box but if I have select-box then how we can validate it using same way as they have used for other text input fields ?

Link to access code from Jquery-UI site

http://jqueryui.com/dialog/#modal-form

In the same way I want to validate my select-box too.

2
  • 4
    show me what you tried ? Commented Feb 23, 2015 at 12:15
  • 1
    what do you want to validate ? What should the rules be ? Any Example to show us ? Commented Feb 23, 2015 at 12:19

1 Answer 1

1

You can check length of selected options and dropdown's value, but this is nasty stuff and there are other ways to do it better and more elegant.

Example:

var $yourDropdown= $('#dropdownElement');
var $options= $('#dropdownElement option:selected');
if ($options.length == 0 || yourDropdown.val() == "")
{
}

More examples HERE, using jQuery Validate

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.