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

Exp 3 Validate Using Javascript

The document describes validating a form using JavaScript. The JavaScript function validateform() validates that the name field is not empty and that the password is at least 6 characters long, alerting the user if either validation fails and returning false to prevent form submission.

Uploaded by

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

Exp 3 Validate Using Javascript

The document describes validating a form using JavaScript. The JavaScript function validateform() validates that the name field is not empty and that the password is at least 6 characters long, alerting the user if either validation fails and returning false to prevent form submission.

Uploaded by

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

Exp 3 Validate Using Javascript

Exp3.html

<html>
<head>
<title>Validatin using Javascript</title>
</head>
<script type="text/javascript">
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<6)
{
alert("Password must be at least 6 characterslong.");
return false;
}

}
</script>
<body>
<form name="myform"
method="post"
action="abc.jsp"
onsubmit="return validateform()">
Name:<input type="text" name="name">
<br>
Password:<input type="password" name="password">
<br>
<input type="submit" name="register">
</form>
</body>
</html>
Output:
Web page:

Error page:
Error page:

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