Java Script Assg
Java Script Assg
Java Script Assg
</script>
</HEAD>
<BODY>
<input type="button" value="Alert" onclick="demo();">
<input type="button" value="Confirm" onclick="demo1();">
<input type="button" value="Prompt" onclick="demo2();">
</BODY>
</HTML>
Fibonacci Series JavaScript Program (for beginners)
This is a simple JavaScript example program for Fibonacci sequence.
<html>
<body>
<script type="text/javascript">
var a=0,b=1,c;
document.write("Fibonacci");
while (b<=10)
{
document.write(c);
document.write("<br/>");
c=a+b;
a=b;
b=c;
}
</script>
</body>
</html>
//Demonstration of document.getElementByID().value;
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<script language= "javascript">
function showname()
{
a=document.getElementById("txtname").value;
alert(a);
}
</script>
</HEAD>
<BODY>
<form>
Name - <input type="text" id="txtname" ><br><br>
<input type="button" value="Show My Name" onclick="showname();" >
</form>
</BODY>
</HTML>
<HTML>
<HEAD>
function funblur()
var x = document.getElementById("fname");
x.value=x.value.toUpperCase();
//Event—OnChange--
function ColorChange()
clr = document.getElementById("color").value;
document.bgColor=clr;
function sel()
{
alert("You can not change price value");
document.getElementById("price").disabled=true;
function pageload()
function pageunload()
function key1()
Key=event.keyCode;
function sub()
</script>
</HEAD>
<option value="Red">Red</option>
<option value="Blue">Blue</option>
<option value="Green">Green</option>
</select><br><br>
</form>
</BODY>
</HTML>
// Demonstrate use of java script form validations. (Minimum Five)
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!doctype html>
<HEAD>
<script language="javascript">
function onlychar()
if((key1>=97&&key1<=122)||(key1>=65&&key1<=90))
return true;
else
return false;
}
function onlynum()
if(key1>=48&&key1<=57)
return true;
else
return false;
function checknull()
m=document.getElementById("txtmob").value;
if(m=="")
document.getElementById("txtmob").focus();
return false;
else if(document.getElementById("txtmob").value.length!=10)
{
alert("Mob No should have min 10");
document.getElementById("txtmob").focus();
function checkpass()
p1=document.getElementById("fpass").value;
p2=document.getElementById("rpass").value;
if(p1!=p2)
document.getElementById("fpass").value="";
document.getElementById("rpass").value="";
document.getElementById("fpass").focus();
return false;
function emailval()
atpos=document.getElementById("email").value.indexOf("@");
dotpos=document.getElementById("email").value.lastIndexOf(".com");
if(atpos<1||dotpos-atpos<2)
{
alert("Invalid Email");
return false;
</script></HEAD>
<BODY>
<form>
</form>
</BODY>
</HTML>
Login Form Using JavaScript Validation
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<h2>LOGIN FROM</h2>
</form>
<script>
function validation(){
var un=document.getElementById('uname').value;
var ps=document.getElementById('pswd').value;
window.alert("Login Successful");
else{
window.alert("Login Failed");
</script>
</body>
</html>
Registration Form
<html>
<head>
<script>
function reg() {
name.focus();
return false;
}
if (address == "") {
address.focus();
return false;
email.focus();
return false;
if (password == "") {
password.focus();
return false;
if(password.length <6){
password.focus();
return false;
}
if (phone == "" || !regPhone.test(phone)) {
phone.focus();
return false;
if (what.selectedIndex == -1) {
what.focus();
return false;
return true;
</script>
<style>
div {
box-sizing: border-box;
width: 100%;
float: left;
align-content: center;
align-items: center;
}
form {
margin: 0 auto;
width: 600px;
</style>
</head>
<body>
<br />
</p>
<br />
<br />
<p>Password: <input type="text" size="65" name="Password" /></p>
<br />
<br />
<p>
<option>MBA</option>
<option>MCA</option>
<option>BCA</option>
</select>
</p>
<br />
<br />
<p>
<input type="submit" value="send" name="Submit" />
</p>
</form>
</body>
</html>
Registration Form 2
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function registration()
if(name=='')
else if(!letters.test(name))
else if(email=='')
else if (!filter.test(email))
alert('Invalid email');
}
else if(uname=='')
else if(!letters.test(uname))
else if(pwd=='')
else if(cpwd=='')
else if(!pwd_expression.test(pwd))
alert ('Upper case, Lower case, Special character and Numeric letter are required in Password
filed');
else
window.location = "https://www.w3schools.com//";
</script>
</head>
<body>
<div id="main">
<div class="h-tag">
</div>
<div class="login">
<table cellspacing="2" align="center" cellpadding="8" border="0">
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
</tr>
<tr>
<td></td>
<td>
</tr>
</table>
</div>
</div>
</body>
</html>