Last-Minute Checking Before Form Submission : Form Submit « Form Control « JavaScript DHTML






Last-Minute Checking Before Form Submission

   

<html> 
<head> 
<title>Validator</title> 
<script type="text/javascript"> 
function checkForm(form) { 
    for (var i = 0; i < form.elements.length; i++) { 
        if (form.elements[i].type == "text" && form.elements[i].value == "") { 
            document.write("Fill out ALL fields."); 
            return false; 
        } 
    } 
    return true; 
} 
</script> 
</head> 
<body> 
<form onsubmit="return checkForm(this)"> 
Please enter all requested information:<br> 
First Name:<input type="text" name="firstName"><br> 
Last Name:<input type="text" name="lastName"><br> 
Rank:<input type="text" name="rank"><br> 
Serial Number:<input type="text" name="serialNumber"><br> 
<input type="submit"> 
</form> 
</body> 
</html> 

   
    
    
  








Related examples in the same category

1.Form Submit action
2.Return the method used when sending form data
3.Submit a form Via Enter
4.Convert a passed form reference to a string formatted like a JavaScript array of objects
5.Use form select control to trigger the action
6.form on submit event
7.Use Image to trigger submit and reset actions
8.Submit a form by sending out an email
9.Adjusting a Server Submission Action
10.Demo: Ajax form submit
11.html input mask