0% found this document useful (0 votes)
11 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)
11 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