Demuri Celidze Demuri Celidze - 27 days ago 4x
HTML Question

How to check if input is not empty on load?

I have a code like this:

<div><input type="text" value=""></div>

How do I check with JS or jQuery if input contain any data (even from localstorage or browser cache) on load and add class to parent div if not empty?


Try this

//trim() is used to remove extra spaces in your input value
if($('#ver_input').val().trim() != ''){


<div><input type="text" value="" id="ver_input"></div>