Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select all input tag in without certain attribute in Jquery

How to select all input tag in without certain attribute and checks each input value not empty in Jquery

Html

<input type="text" maxlength="255" value="" id="UserName" class="form-error"  >
<input type="text" maxlength="255" value="" id="Password" class="form-error">
<input type="text" maxlength="255" value="" id="Group" class="form-error" inputname="test" >
<input type="text" maxlength="255" value="" id="Aka" class="form-error" inputname="money" >

I want to select all inputs from the current page which dont have attribute as 'inputname'.

Something like

In javascript

var inputs = $('input:not(:has(>[inputname]))');

jQuery.each(inputs, function(input) {
      if (input.value == '')  {
   $(input).next().removeClass('displayNone');
       return false;
   }
});
like image 396
Justin John Avatar asked Nov 04 '22 04:11

Justin John


1 Answers

I believe you want

var inputs = $('input:not([inputname])');

Live example

like image 71
T.J. Crowder Avatar answered Nov 07 '22 23:11

T.J. Crowder