I've been searching around and all the answers I've seen will use something along the lines of $('form :input')$ to get all of the inputs. But I already have a reference to the form using $("form").submit() and I just need to grab a specific input field from the fieldname. I'm unsure of how to use $(this) with additional selectors to get the forms specific elements
So, how would I go about doing that.
Example of the bit of code I need to workout.
$('form').submit(function(){
var form = $(this)
var form_errors = array_of_errors
for(var fieldname in form_errors){
var errors = form_errors[fieldname]
var field = \\how to get this
\\ Something like $(form, 'input[name='+fieldname+']') maybe?
}
});
$('input[name='+fieldname+']', form)the correct syntax. documentation here$(":input", form)retrives all input elements$onvar form = $(this)on the initial function part below.submit(). Sovar form = thisworked. And I had it backwards. Post as solution?$('input[name="'+fieldname+'"]', form)if you have special chars in you name