0

I am using jquery form validator to validate all my fields in the form.

In form validator I am using following code to see if a input field has the name minExperience.

errorPlacement: function(error, element) {
    if(/*Want to check if the `element` has the name = "minExperience"*/) 
    {
        error.insertAfter($('#skillBtn'));
    }
}

So that I can place the error message after $('#skillBtn').

I am not able to figure out what to write in the if condition.

Please help.

0

4 Answers 4

3

Try this,

errorPlacement: function(error, element) {
    if(element.attr('name')=='minExperience') 
    {
        error.insertAfter($('#skillBtn'));
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

I have one more question: How do I select this label: <label for="minExperience">Experience</label>
You can use if(element.attr('name')=='minExperience' || $('label').attr('for')=="minExperience")
2

You can use $('input[name=\'name_field\']').val() and then compare it depends your conditions.

Comments

1

If you are looking for <input name="minExperience" /> you can do

alert($('input[name="minExperience"]').val())

Comments

0

Simply put as

 if (element.attr("name") == "minExperience")
 {
           error.insertAfter($('#skillBtn'));
 }

1 Comment

How could I have? We probably checked the same source. I checked the Jquery site for references and provided the snippet here.

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.