Javascript examples for Statement:if
Verifying text box content with if statement
<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <script type="text/javascript"> function check() {/*from ww w .j av a 2 s. c o m*/ if(document.getElementById("sometext").value == '') { console.log('Field is empty'); } else { console.log('Field is not empty'); } } </script> </head> <body> <input type="text" id="sometext" value=""> <input type="button" id="check" onclick="check();" value="Check if empty"> </body> </html>