<html> <head> <script type="text/javascript"> function validate() { var a = document.getElementById("name").value; if(a.length==0) { document.getElementById("warning").innerHTML="Please enter your name"; } if(a.length!=0) { document.getElementById("warning").innerHTML=""; document.getElementById("success").innerHTML="Length of your name is "+a.length; } } </script> </head> <body> <style> div { color:#ff0000; } </style> <h3 align="center">Blank Validation & Length Validation </h1> <label>Enter your name:</label> <input type="text" id="name"/><div id="warning"> </div> <input type="Submit" id="validate" value="validate" onclick="validate()"/> <div id="success"> </div> </body> </html>
JS - Blank Validation & Length
0
December 13, 2022
Tags