Justin John
Justin John

Reputation: 9616

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;
   }
});

Upvotes: 5

Views: 3337

Answers (3)

darryn.ten
darryn.ten

Reputation: 6973

$('input:not([inputname])') should do the trick?

Upvotes: 1

T.J. Crowder
T.J. Crowder

Reputation: 1074138

I believe you want

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

Live example

Upvotes: 5

Srikanth Kshatriy
Srikanth Kshatriy

Reputation: 444

Use this var input = $(":input");

Upvotes: -4

Related Questions