0

I am trying to check if the number input element is empty using jquery

<input type="number" name="year" id="year" min="1900" max="2017">
1
  • if ( $('#year').val() === "" ) {.. Commented Aug 28, 2017 at 15:00

1 Answer 1

2

Here is an example:

if($("#year").val() == "" || $("#year").val() == null){
    //code goes here
}

You just have to target the element by ID, get its value and check if its an empty string or null.

Hope this helps!

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

1 Comment

Just if (!$("#year").val()) { will do.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.