Experiment_No_6[1]
Experiment_No_6[1]
Experiment_No_6[1]
:-6
Object:-Write Java Script to validate the following fields of the registration page.
1.) Name (Name should contains alphabets and the length should not be less
than 6 characters).
2.) Password (Password should not be less than 6 characters length).
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible"content="IE=edge">
<metaname="viewport"content="width=device-width,initial-scale=1.0">
<title>Registration Form JS Validation</title>
<!—Latest compiled and minified CSS-->
<link rel="stylesheet"href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css">
<!—jQuery library-->
<script src="https://cdn.jsdelivr.net/npm/jquery@3.7.1/dist/jquery.slim.min.js"></script>
<!--PopperJS-->
<scriptsrc="https://cdn.jsdelivr.net/npm/popper.js@1.16.1/dist/umd/popper.min.js"></script>
<div class="form-group">
<label>UserName:</label>
<input type="text" name="user" class="form-control" id="user"autocomplete="off">
<span id="username" class="text-danger font-weight-bold"></span>
</div>
<divclass="form-group">
<label>Password:</label>
<input type="password" name="pass" class="form-control" id="pass" auto
complete="off">
<span id="password"class="text-danger font-weight-bold"></span>
</div>
<!—JS Validation-->
<script type="text/javascript">
function validation(){
var user=document.getElementById('user').value;
var pass = document.getElementById('pass').value;
if(user==""){
document.getElementById('username').innerHTML = "** Please fill the UserName
field";
return false;
}
if(user.length<=6){
document.getElementById('username').innerHTML = "** Name length should not be
less than 6 characters";
return false;
}
else{
document.getElementById('username').innerHTML="";
}
if(pass==""){
document.getElementById('password').innerHTML = "** Please fill the Password
field";
return false;
}
if(pass.length<=6){
document.getElementById('password').innerHTML = "** Password length should not
be less than 6 characters";
return false;
}
else{
document.getElementById('password').innerHTML="";
}
}
</script>
</body>
</html>
VAISHNAVI GUPTA
CSE(DS) 2
2301201540052