0% found this document useful (0 votes)
52 views

Validation (6) HTML

This document contains the code for a registration form with various input fields like name, email, phone, etc. and validations for these fields. On submitting the form, a JavaScript function checks if the fields are empty or in incorrect format and alerts the user. It also checks password length and selected course. If all validations pass, it returns true, otherwise it returns false.

Uploaded by

ernest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views

Validation (6) HTML

This document contains the code for a registration form with various input fields like name, email, phone, etc. and validations for these fields. On submitting the form, a JavaScript function checks if the fields are empty or in incorrect format and alerts the user. It also checks password length and selected course. If all validations pass, it returns true, otherwise it returns false.

Uploaded by

ernest
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

11/17/22, 3:01 PM Validation(6).

html

1
2
3 <!DOCTYPE html>
4 <html>
5 <head>
6 <script>
7 function main() {
8 var name =
9 document.forms.RegForm.Name.value;
10 var email =
11 document.forms.RegForm.EMail.value;
12 var phone =
13 document.forms.RegForm.Telephone.value;
14 var what =
15 document.forms.RegForm.Subject.value;
16 var password =
17 document.forms.RegForm.Password.value;
18 var address =
19 document.forms.RegForm.Address.value;
20 var regEmail=/^\w+([\.-]?\w+)@\w+([\.-]?\w+)(\.\w{2,3})+$/g; //Javascript
reGex for Email Validation.
21 var regPhone=/^\d{10}$/; // Javascript reGex for Phone
Number validation.
22 var regName = /\d+$/g; // Javascript reGex for Name
validation
23
24 if (name == "" || regName.test(name)) {
25 window.alert("Please enter your name properly.");
26 name.focus();
27 return false;
28 }
29
30 if (address == "") {
31 window.alert("Please enter your address.");
32 address.focus();
33 return false;
34 }
35
36 if (email == "" || !regEmail.test(email)) {
37 window.alert("Please enter a valid e-mail address.");
38 email.focus();
39 return false;
40 }
41
42 if (password == "") {
43 alert("Please enter your password");
44 password.focus();
45 return false;
46 }
47
48 if(password.length <8){
49 alert("Password should be atleast 6 character long");
50 password.focus();
51 return false;
52
53 }
54 if (phone == "" || !regPhone.test(phone)) {
55 alert("Please enter valid phone number.");
56 phone.focus();

localhost:4649/?mode=htmlmixed 1/3
11/17/22, 3:01 PM Validation(6).html

57 return false;
58 }
59
60 if (what.selectedIndex == -1) {
61 alert("Please enter your course.");
62 what.focus();
63 return false;
64 }
65
66 return true;
67 }
68 </script>
69
70 <style>
71 div {
72 box-sizing: border-box;
73 width: 100%;
74 border: 100px solid black;
75 float: left;
76 align-content: center;
77 align-items: center;
78 }
79
80 form {
81 margin: 0 auto;
82 width: 600px;
83 }
84 </style>
85 </head>
86
87 <body>
88 <h1 style="text-align: center;">REGISTRATION FORM</h1>
89 <form name="RegForm" onsubmit="return GEEKFORGEEKS()" method="post">
90
91 <b>
<p>NAME<b>:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbs
p <input type="text"
92 size="65" name="Name" /></p>
93
94 <br />
95
96 <p>ADDRESS:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="text"
97 size="65" name="Address" />
98 </p>
99
100 <br />
101
102 <p>E-MAIL ADDRESS: <input type="text"
103 size="65" name="EMail" /></p>
104
105 <br />
106
107 <p>PASSWORD:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp <input type="text"
108 size="65" name="Password" /></p>
109
110 <br />
111
112 <p>TELEPHONE:&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<input type="text"
113 size="65" name="Telephone" /></p>
114
localhost:4649/?mode=htmlmixed 2/3
11/17/22, 3:01 PM Validation(6).html

115 <br />


116
117
118 <p>
119 SELECT YOUR COURSE
120 <select type="text" value="" name="Subject">
121 <option>BCA</option>
122 <option>BBA</option>
123 <option>BTech</option>
124 <option>B.COM</option>
125 <option>MBA</option>
126 <option>BSc.comp</option>
127 <option>BSc.Sci</option>
128 <option>BA</option>
129 <option>Hardware Course</option>
130 <option>Software Course</option>
131 <option>Fashion Designing</option>
132 <option>Cosmotology Course</option>
133 </select>
134 </p>
135
136 <br />
137 <br />
138
139 <p>COMMENTS:&nbsp <textarea cols="55"
140 name="Comment"> </textarea></p>
141
142
143 <p>
144 <input type="submit"
145 value="send" name="Submit" />
146 <input type="reset"
147 value="Reset" name="Reset" />
148 </p>
149
150 </form>
151 </body>
152 </html>

localhost:4649/?mode=htmlmixed 3/3

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy