Reputation: 5758
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.
Upvotes: 0
Views: 896
Reputation: 511
Simply put as
if (element.attr("name") == "minExperience")
{
error.insertAfter($('#skillBtn'));
}
Upvotes: 0
Reputation: 1499
You can use $('input[name=\'name_field\']').val()
and then compare it depends your conditions.
Upvotes: 2
Reputation: 40639
Try this,
errorPlacement: function(error, element) {
if(element.attr('name')=='minExperience')
{
error.insertAfter($('#skillBtn'));
}
}
Upvotes: 3
Reputation: 99660
If you are looking for <input name="minExperience" />
you can do
alert($('input[name="minExperience"]').val())
Upvotes: 1