Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
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">
if ( $('#year').val() === "" ) {..
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!
Add a comment
if (!$("#year").val()) {
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
if ( $('#year').val() === "" ) {..