Posted in

Student Registration Form Validation Using HTML and JavaScript

Simple Form Validation Using HTML and JavaScript  

In this post, we can learn about a simple student registration form in HTML with javascript validation form using the javascript program. Simple and basic Code using this Form Validation.

These are easily created by HTML code with Javascript. In this form you can check the user input information is correct or wrong using javascript code to avoid wrong information about the user. 

We should use simple editor software like Sublime Text or Notepad++ etc…

1.File Name [Student.html]

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!DOCTYPE html>
<html>
<head>
	<title>Html Form page</title>

<script>
	function validateform(){
		var fname = document.form.fname.value;
		var lname = document.form.lname.value;
		var age = document.form.age.value;
		var email =document.form.email.value;
		var emailformat =  /^w+([.-]?w+)*@w+([.-]?w+)*(.w{2,3})+$/; 
		if (fname =="") {
			alert("Pleas Fill  firstname");
			document.form.fname.focus();
			return false;
		}
		else if(lname == ""){
			alert("please Fill last name")
			document.form.lname.focus();
			return false;

		}
		else if (age =="") {
			alert("please Fill AGE")
			document.form.age.focus();
			return false;

		}
		else if (email =="") {
			alert("please Fill email")
			document.form.email.focus();
			return false;
		}
		}
		
		function onfocuscolor(){
			document.getElementById("address").style.background="yellow"; 

		} 
     </script>
</head>
<body>
<h1 align="center">STUDENT REGISTRATION FORM</h1>  

<form name="form" action="register.html" method="post" onsubmit=" return validateform()">
	
         <label for="fname"><b>1.FIRST NAME:</b></label>
         <input type="text" id="fname" name="fname"><br><br>
         <label for="lname"><b>2.LAST NAME:</b></label>
         <input type="text" id="lname" name="lname"><br><br>
         <label for="age"><b>3.YOUR AGE:</b></label>
         <input type="text" id="age" name="age" onkeyup="numbersonlyallwed(this)"><br><br>
         <label for="email"><b>4.EMAIL ID:</b></label>
         <input type="email" id="email" name="email"><br><br>
         <label for="birthday"><b>5.DATE OF BIRTH</b></label>
		 <input type="date" id="birthday" name="birthday"><br><br>
		<label><B>6.GENDER</B></label><br>
		<input type="radio" id="gender" name="gender" value="Male"/>Male<br>
		<input type="radio" id="gender" name="gender" value="Female"/>Female<br>
		<input type="radio" id="gender" name="gender" value="Other"/>Other<br><br>
		<label><B>7.CHOOSE YOUR DEPARTMENT</b></label>
  <select>
    <option value="volvo">B.TECH (IT) </option>
    <option value="saab">BE (MECH)</option>
    <option value="fiat">BE (CIVIL)</option>
    <option value="audi">BE (ECE)</option>
  </select><br><br>
  <label for="number"><b>8.COLLAGE NAME:</b></label>
		 <input type="text" id="collage_name" name="collage_name"><br><br>
  <label for="number"><b>9.MOBILE NUMBER:</b></label>
		 <input type="text" id="number" name="number"><br>
		
	<br><B>10.ENTER YOUR ADDRESS</b><br>
		<textarea id="address" onfocus="onfocuscolor()"></textarea><br><br>
		<input type="submit" value="REGISTRATION"><br><br>
</form>
</body>
</html>

OUTPUT

How To Run the Program

Step 1: Copy this code.

Step 2: Paste Your favorite  Code editor Like Notepad etc,,

Step 3: Save the file .html

Step 4: Finally run the program in your browser.

I am a Software Engineer with a strong interest in writing technology-related articles, managing two websites. I am dedicated to learning new technologies and producing engaging content. Additionally, I possess expertise in digital marketing and SEO strategies.

Leave a Reply

Your email address will not be published. Required fields are marked *