MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

JavaScript Tutorial

Validation In Javascript
Previous Home Next

javascript provide a several type of validation and its also provide difference facilities in the validation forms The idea behind JavaScript form validation is to provide a method to check the user entered information before they can even submit it .

JavaScript also lets you display helpful alerts to inform the user what information they have entered by user that's correct or in correct .

form validation example :

Form validation is the process of checking that a form has been filled in correctly before it is processed.

<html>
<head>    

<script>  
       function validateform(){  
        var name=document.myform.name.value;  
        var password=document.myform.password.value;  
      
            if (name==null || name==""){  
               alert("Name can't be blank");  
                 return false;  
    }else if(password.length<10){  
             alert("Password must be at least 10 characters long.");  
      return false;  
      }  
    }  
    </script>  
    <body>  
    <form name="myform" method="post" action=" " onsubmit=
	"return validateform()" >  
    Name: <input type="text" name="name"><br/>  
    Password: <input type="password" name="password"><br/>  
    <input type="submit" value="register">  
    </form> 
</html>
</head>   

Output :

 

Number Validation :

<html>
<head>

<script >
    function lengthRestriction(elem, min, max){
	var Input = elem.value;
	if(Input.length >= min && Input.length <= max){
		return true;
	}else{
		document.write (
		"Please enter between " +min+ " and " 
		
		+max+ " characters");
		
		return false;
	}
}
</script>
<form>
Username(10-50 
characters): <input type='text' id='prasun'
/>
<input type='button' 
	onclick="lengthRestriction(document.getElementById('prasun'), 10, 50)
	"value='button' />
</form>
</head>
</html>

Output :

Please enter between 10 and 50 characters

Previous Home Next