0% found this document useful (0 votes)
10 views2 pages

HTML Form Validation Example

The document is an HTML file for a simple information form that includes fields for name, address, contact number, and email. It features basic form validation for the email address using JavaScript, checking for the presence of '@' and '.' characters. The form has a submit button that triggers the email validation function when clicked.

Uploaded by

smitsalvi30621
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)
10 views2 pages

HTML Form Validation Example

The document is an HTML file for a simple information form that includes fields for name, address, contact number, and email. It features basic form validation for the email address using JavaScript, checking for the presence of '@' and '.' characters. The form has a submit button that triggers the email validation function when clicked.

Uploaded by

smitsalvi30621
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

Code :

[Link]
<!doctype html>
<html>
<head>
<title>Form Validation</title>
<style>
form {border-width:5px; border-style:solid}
</style>
</head>
<body>
<h1> Information Form </h1>
<form name = "f1"><br><br>
Your Name:- <input type = text name = "txt1-nm"> <br> <br>
Address :- <textarea name = "txtar1" rows=2 cols = 30 placeholder="Parmanent Address">
</textarea><br> <br>
Contact :- <input type = tel name = "telno1" maxlength = 10> <br> <br>
Email :- <input type = email name = "email1" pattern = "[A-Z a-z]{0-9}-[@]{1}-[.]{1}"><br> <br>
<input type = button name = b1 value = "Submit" onclick="validate_email()"><br><br>
</form>
</body>
<script type = "text/javascript">
function validate_email()
{
var x=[Link];
var at_pos=[Link]("@");
var last_pos=[Link]("@");
var firstdot_pos=[Link](".");
var dot_pos=[Link](".");
if
(at_pos<1||dot_pos<at_pos+2||dot_pos+2>=[Link]||firstdot_pos<at_pos||at_pos<last_pos)

{
alert("Not an Valid email Address");
[Link]();
}
else
{
alert ("Valid Email Address");
return true;
}
}
</script>
</html>

Out Put :

You might also like