5

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

3 Answers 3

5

I believe you want

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

Live example

Sign up to request clarification or add additional context in comments.

2 Comments

Is it possible to use multiple selector in not $('input:not([inputname] [type="hidden"])');
@Jusnit: :not takes only a "simple selector". So you string them together, e.g. $('input:not([inputname]):not([type="hidden"])').
1

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

1 Comment

When you see you've posted a duplicate answer, it's best to remove it.
-4

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

1 Comment

I want all inputs , but dont contain attribute inputname

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.