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

JS Validation

Uploaded by

ritiktyagi0123
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)
4 views

JS Validation

Uploaded by

ritiktyagi0123
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

<html>

<head>

<title>Js Validation</title>

</head>

<body>

<h2>JS Validation Form</h2>

<form name="userform">

<label for="user">Enter Username : </label>

<input type="text" name="user" id="user"><br><br>

<label for="password">Enter Password : </label>

<input type="password" name="password"


id="password"><br><br>

<input type="button" value="Submit" onclick="passUserForm()">

</form>

<script language="javascript">

function isValid(c) {

return /^[a-zA-Z]$/.test(c);

function passUserForm() {

var UserName = userform.user.value

if (UserName === "") {

alert("UserName must be Filled");

} else if (UserName.length < 6) {

alert("UserName must be at least 6 characters long!");

} else {

var valid = true;

for (var i = 0; i < UserName.length; i++) {

var c = UserName[i];

if (!isValid(c)) {
alert("UserName must be contains only alphabets");

valid = false;

break;

} if (valid) alert("Username accepted successfull");

var password = userform.password.value

if (password === "") {

alert("Password must be Filled");

} else if (password.length < 6) {

alert("Password must be at least 6 characters long!");

} else {

alert("Password accepted successfull");

} </script>

</body>

</html>

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