Is there any way to check if a specific form has any input fields in it? Or if it has no input fields?
Update:
Also how do I return the focus to a button on page load if the condition is met?
The below doesn’t seem to work
var numInputs = $("#forgotPassword").find("input:visible").length;
if(numInputs == 0){
$('.button-class > a').focus();
}
I would just select all the inputs inside the form and check to see how many come back
And of course if you’d like to include textareas and selects
or more simply:
EDIT
To exclude hidden inputs, you can use the
:visiblepseudoselector