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.


<!DOCTYPE html>
<html lang="en">
function notEmptyCheck(name)
if (name.value.length == 0)
         alert("Name can not be empty.");  	
         return false; 
      return true; 
<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("/>
Content Protection by
Please Share