CodesJava

Easy learning with example program codes

not empty validation JavaScript JS

Not empty or blank field validation is used to check whether anything is entered in a given field or not. It will check for null and zero length string.

Example

<!DOCTYPE html>
<html lang="en">
<head>
<script> 
function notEmptyCheck(name)
{
if (name.value.length == 0)
      { 
         alert("Name can not be empty.");  	
         return false; 
      }  	
      return true; 
}    
</script> 
</head>
<body>
<div>
<h2>JavaScript Not Empty Validation</h2>
<form name="form1" action="#"> 
Name: <input type='text' name='name'/></br></br>
<input type="submit" name="submit" value="Submit" onclick="notEmptyCheck(document.form1.name)"/>
</form>
</div>
</body>
</html>
Please follow and like us:
error








Copyright © 2019 CodesJava DMCA.com Protection Status