Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How in Jquery do I select the first blank input which is not a check box or a button

Tags:

jquery

How in Jquery do I select the first blank input which is not a check box or a button. I have the following:

$(':input[value="",type!="button",type!="checkbox"]:visible:first').focus(); 

Thanks for any suggestions

like image 331
suzi167 Avatar asked Feb 22 '11 20:02

suzi167


2 Answers

Tiny bit shorter

$("input[value='']:not(:checkbox,:button):visible:first").focus();
like image 61
Richard Dalton Avatar answered Sep 20 '22 10:09

Richard Dalton


$('#formid')
  .find('input:blank:not(:checkbox,:button)')
  .filter(":visible:enabled")
  .first()
  .focus();

(During my testing, input[value=''] worked only for pre-filled empty input fields; input:blank didn't have that problem.)

like image 29
Rohit Dubey Avatar answered Sep 17 '22 10:09

Rohit Dubey