Solved

jquery validation highlight

Posted on 2009-03-31
4
1,014 Views
Last Modified: 2012-06-27
Hello,

I'm trying to use jquery validation highlight method but I get an error:

highlight: function(element, errorClass) {
     if (element.attr("name") == "aupairLanguageList")
        $("#multiSelect-aupairLanguageList-title").addClass("error");
  },
  unhighlight: function(element, errorClass) {
     if (element.attr("name") == "aupairLanguageList")
        $("#multiSelect-aupairLanguageList-title").removeClass("error");
  }


"element.attr is not a function"

Any ideas?

Thanks
0
Comment
Question by:Steggs
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Albert Van Halen earned 300 total points
ID: 24033125
element is the DOM element.
You have to create a jquery object to use attr method
Use $(element).attr()
0
 
LVL 2

Assisted Solution

by:captaincagemen
captaincagemen earned 200 total points
ID: 24033142
Try it like this:
highlight: function(element, errorClass) {

     if ($(element).attr("name") == "aupairLanguageList")

        $("#multiSelect-aupairLanguageList-title").addClass("error");

  },

  unhighlight: function(element, errorClass) {

     if ($(element).attr("name") == "aupairLanguageList")

        $("#multiSelect-aupairLanguageList-title").removeClass("error");

  }

Open in new window

0
 
LVL 19

Assisted Solution

by:Albert Van Halen
Albert Van Halen earned 300 total points
ID: 24033158
Here's the code
You could also refer to the name attribute of the DOM element directly using element.name
// Using jquery

highlight: function(element, errorClass) {

     if ($(element).attr("name") == "aupairLanguageList")

        $("#multiSelect-aupairLanguageList-title").addClass("error");

  },

  unhighlight: function(element, errorClass) {

     if ($(element).attr("name") == "aupairLanguageList")

        $("#multiSelect-aupairLanguageList-title").removeClass("error");

  }
 

//using DOM

highlight: function(element, errorClass) {

     if (element.name == "aupairLanguageList")

        $("#multiSelect-aupairLanguageList-title").addClass("error");

  },

  unhighlight: function(element, errorClass) {

     if (element.name == "aupairLanguageList")

        $("#multiSelect-aupairLanguageList-title").removeClass("error");

  }

Open in new window

0
 
LVL 30

Author Closing Comment

by:Steggs
ID: 31565008
Thanks
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SharePoint Online Adding A People Picker to Search 14 48
Jquery autocomplete 10 68
javascript date picker in php while loop 5 28
Angular - disable input field on page load 4 14
Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now