We help IT Professionals succeed at work.
Get Started

jquery ui selectmenu validation

Last Modified: 2015-03-09
Hello experts.
I m validating my form using Jquery validation plugin. Because i want to style my selectmenus with jquery ui i have a problem with error and valid styling of the ui select elements
using the errorPlacement i m able to style the ui element adding ui-state-error class
The problem is to show the ui-state-valid on validation.
Any help?
My js code:
var selectone = 'Please select';
	  transferClasses: true,
      width: null,
      change: function() {
		var id = $(this).attr('id');
	   // $('#' + id + '-button,#' + id + '-menu').removeClass('ui-s<wbr ></wbr><wbr ></wbr>tate-error<wbr ></wbr> ui-state-valid');
	jQuery.validator.addMethod("selectNone", function(a) {return true});
        errorPlacement: function(a, b) {
				var id = b.attr('id');
	            $('#' + id + '-button,#' + id + '-menu').removeClass('ui-state-error ui-state-valid');
				$('#' + id + '-button,#' + id + '-menu').addClass('ui-state-error');
			else {
		ignore: [],
		rules: {
            selectmenu_1: {required: true},
            selectmenu_2: {required: true},
            selectmenu_3: {required: false,selectNone: true}
        messages: {
            selectmenu_1: selectone,
            selectmenu_2: selectone  

Open in new window

Watch Question
Owner (Aidellio)
Most Valuable Expert 2015
This problem has been solved!
Unlock 1 Answer and 8 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE