It’s a good practice to validate your form using script before sending because it’s giving quick response than server validity. But keep in mind server validation is always necessary because JavaScript may be disabled by the user. So server validation is mandatory. I am presenting complete code for validating a check box, textbox and file. My main focus is on file validating because file validation is complicated task for new web developers So this will help you a lot.
<html>
<head>
<title>Java script form validation ; Girfa</title>
<script language="javascript">
function validate_mar_news(pic,fl,code) //validate add news pic for home page marquee
{
var check_box=document.getElementById(pic);
var file=document.getElementById(fl);
var code=document.getElementById(code);
var flag=true;
if(check_box.value=="Select Page Number")
{
<html>
<head>
<title>Java script form validation ; Girfa</title>
<script language="javascript">
function validate_mar_news(pic,fl,code) //validate add news pic for home page marquee
{
var check_box=document.getElementById(pic);
var file=document.getElementById(fl);
var code=document.getElementById(code);
var flag=true;
if(check_box.value=="Select Page Number")
{