2010
09.12

Recently I was playing with jQuery form validation, and I ran into a problem.

I wanted to customize the error message accoring to the form element, when a validation error occures.
For example, I can’t give the same error message to a text field, and a select dropdown list. Even in English you’d print out ‘Please, fill in the form’, and ‘Please, select from the list’ or something like that.

I wanted to do the switch between these to formulas, by detecting the input forms node name.
Why is in DOM simply nodeName, but if you try it with jQuery it would say undefined:

1
alert(jQuery("#input_name").nodeName);

The solution is so over here:

1
alert(jQuery("#input_name").get(0).nodeName);

1 comment so far

Add Your Comment
  1. After researching a lot, i have found your article! it just fits! do you know why this works this way? what does the get function do?

    cheers!