Skip to content
Advertisement

Check if value is empty javascript

After submitting I want the redirect the users to a different page with the value of the input in the url. Now, when there is no value I want that it does nothing (return false). How can I do this?

My current code:

JavaScript

Advertisement

Answer

You have two ways to do that. With JavaScript:

JavaScript
JavaScript

Or you can use the HTML5 required attribute:

JavaScript

Now its up to you! 😀

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement