EMAIL VALIDATION
<html>
<head>
<title>Check Email Address</title>
<script language="javascript">
function checkEmail(inputvalue)
{
var pattern=/^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z])+([a-zA-Z])+/;
if(pattern.test(inputvalue))
{
alert("Valid Email");
}
Else
{
alert("Invalid Email id please enter correct format");
}
}
</script>
</head>
<body>
<form name="signupform">
<h1> Email Validation </h1>
<br>
<br>
Input your email: <input name="email" type="text" >
<input type="submit" value="Check"
onClick="checkEmail(document.signupform.email.value)">
</form>
</body>
</html>
DIGITAL CLOCK
<html>
<head>
<Script Language="JavaScript">
function starttime()
{
var today=new Date();
var h=today.getHours();
var m=today.getMinutes();
var s=today.getSeconds();
m=checktime(m);
f1.t1.value=h+":"+m+":"+s;
setTimeout("starttime(),500");
}
function checktime(i)
{
var i;
if(i<10)
{
i="0"+i;
}
return i;
}
</Script>
</head>
<body onload="starttime()">
<center><h1>Digital Clock</h1>
<table cellpadding="10" border="5">
<tr>
<td bgcolor="green">
<form name=f1>
<input type=text name=t1>
</form>
</td></tr>
</table>
</center>
</body>
</html>
SIMPLE CALCULATOR
<html>
<head>
<title>arithmatic</title>
<script language="vbscript">
dim a,b
Function fun1()
a=document.f1.t1.value
b=document.f1.t2.value
document.f1.t3.value=cint(a)+cint(b)
End Function
Function fun2()
a=document.f1.t1.value
b=document.f1.t2.value
document.f1.t3.value=cint(a)-cint(b)
End Function
Function fun3()
a=document.f1.t1.value
b=document.f1.t2.value
document.f1.t3.value=cint(a)*cint(b)
End Function
Function fun4()
a=document.f1.t1.value
b=document.f1.t2.value
document.f1.t3.value=cint(a)/cint(b)
End Function
</script>
</head>
<body>
<form name="f1">
<center>
a value:<input type="text" name="t1"><br>
b value:<input type="text" name="t2"><br>
Result:<input type="text" name="t3"><br><br>
<input type="button" name="b1" value="add" onclick="fun1()">
<input type="button" name="b2" value="sub" onclick="fun2()">
<input type="button" name="b2" value="mul" onclick="fun3()">
<input type="button" name="b2" value="div" onclick="fun4()">
</center>
</form>
</body>
</html>
SELECT YOUR ITEM USING DROP DOWN LIST BOX
<html>
<head>
<title>Select Your Option</title>
<script language="vbscript">
dim rate,rate1,item,idx,no_item,famt
sub item1_onChange()
idx=document.form1.item1.SelectedIndex
item=document.form1.item1.options(idx).text
Msgbox "you have chosen:"&item
Select case item
case "Dhoshai" rate=25
case "Pongal" rate=28
Case "Idally" rate=20
Case "Chapathi" rate=30
End select
Msgbox" The Price is:"&rate
no_item=Inputbox("Enter number of item")
famt=cint(no_item)*cint(rate)
Document.form1.amt.value=famt
End sub
sub item2_onChange()
idx=document.form1.item2.SelectedIndex
item=document.form1.item2.options(idx).text
Msgbox "you have chosen:"&item
rate1=25
Msgbox" The Price is:"&rate
Document.form1.amt.value=famt+rate1
End sub
</script>
</head>
<body>
<form name="form1">
<h2>Select Your Item From this List</h2>
Item:<Select name="items" multiple="true">
<option>Dhoshai</option>
<option>Pongal</option>
<option>Idally</option>
<option>Chapathi</option>
<option>Parotta</option>
</select>
Available Item:<Select name="item1">
<option>Dhoshai</option>
<option>Pongal</option>
<option>Idally</option>
<option>Chapathi</option>
</select>
SoftDrink:<Select name="item2">
<option>Milkshake</option>
<option>Fresh juise</option>
<option>PEPSI</option>
<option>FROOTY</option>
<option>MASAA</option>
</select>(*All Soft Dring has Rs.25/-)<br><br><br>
Amount:<input type="text" name="amt" ReadOnly>
</form>
</body>
</html>
SQUARES, ROOTS, CUBES AND COMPLEMENTS OF INTEGERS BETWEEN 1 AND
100
<html>
<head>
<title>
squares,roots,cubes and complements of integer between 1 to 100.</title>
</head>
<body>
<h1>squares,roots,cubes and complements of integer between 1 to 100.</h1>
<script language = "javascript">
document.write("<table
border=1><tr><td>squares</td><td>cubes</td><td>complements</td></tr>");
for(i=1;i<=100;i++)
{
document.write("<tr><td>"+i*i+"</td><td>"+i*i*i+"</td><td>"+
"</td><td>"+~i+"</td></tr>");
}
</script>
<form>
</form>
</body>
</html>
SCROLLING TEXT ON WINDOWS STATUS BAR
<html>
<head>
<title>javascript</title>
<script language="javascript" type="text/javascript">
var scrollcounter = 0;
var scrolltext = "welcome to javascript";
var scrolldelay = 70;
var i = 0;
while (i ++ < 140)
scrolltext = " " + scrolltext;
function scroller()
{
window.status = scrolltext.substring(scrollcounter++, scrolltext.length);
if (scrollcounter == scrolltext.length)
scrollcounter = 0;
settimeout("scroller()", scrolldelay);
}
scroller();
</script>
</head>
<body bgcolor="green">
<center><h1>scrolling text on windows status bar</h1></center>
<input type="button" onclick="scroller()" value="click here">
</body>
</html>
USING FRAMES TO VIEW THE WEB PAGE
Frames.html
<html>
<head>
<title>using frames </title>
</head>
<frameset cols =25%,70% border =1>
<frame src ="frame.html" >
<frame src ="" width = 100 height = 300 name ="sample">
</frame>
</frameset>
</html>
Frame.html
<html>
<form name = f1>
<a href ="yahoo.html" target = "sample">yahoo</a>
<a href ="vista.html" target = "sample">ltavista</a>
<a href ="seek.html" target = "sample">infoseek</a>
</form>
</html>
yahoo.html
<html>
<body bgcolor ="pink">
<h1>welcome to yahoo websearch
</body>
</html>
vista.html
<html>
<body bgcolor ="blue">
<h1>welcome to vista websearch
</body>
</html>
seek.html
<html>
<body bgcolor ="red">
<h1>welcome to yahoo websearch
</body>
</html>
HIT COUNTER
<html>
<head>
<title>Hit Counter</title>
<script language="javascript">
now = new Date
expireDate = new Date
expireDate.setMonth(expireDate.getMonth()+6)
hitCt = parseInt(cookieVal("pageHit"))
hitCt++
lastVisit = cookieVal("pageVisit")
if (lastVisit == 0)
{
lastVisit = ""
}
document.cookie = "pageHit="+hitCt+";expires=" + expireDate.toGMTString()
document.cookie = "pageVisit="+now+";expires=" + expireDate.toGMTString()
function cookieVal(cookieName)
{
thisCookie = document.cookie.split("; ")
for (i=0; i<thisCookie.length; i++)
{
if (cookieName == thisCookie[i].split("=")[0])
{
return thisCookie[i].split("=")[1]
}
}
return 0
}
</script>
</head>
<body>
<h2> Hit Count Program Using Cookies<br>
<script type="text/javascript" language="javascript">
document.write("You have Visited this Page " + hitCt + " times.")
if (lastVisit != "")
{
document.write("<br />Your last Visit was " + lastVisit)
}
</script>
</h2>
</body>
</html>
SORTING NUMBERS AND STRING
<html>
<h1 align =center> Sorting Numbers and Strings</h1>
<head>
<title>
Sorting Numbers and Strings
</title>
<script type="text/javascript">
var fruits = ["Banana", "Orange", "Apple", "Mango"];
document.writeln("Sorting Strings:" +fruits.sort() +"<br />");
var n = ["4", "7", "9", "1"];
document.writeln("Sorting Numbers:"+n.sort());
</script>
</head>
<body>
</body>
</html>
ON MOUSE OVER EVENT
<html>
<head>
<title>
changing image</title>
<script>
function imageinit()
{
img1on = new Image();
img1off = new Image();
img1on.src="star1.jpg";
img1off.src="star2.jpg";
}
function imageSwitchOn(imagename)
{
imageOn=eval(imagename+"on.src");
document[imagename].src=imageOn;
}
function imageSwitchOff(imagename)
{
imageOff=eval(imagename+"off.src");
document[imagename].src=imageOff;
}
</script>
</head>
<body onLoad="imageinit()">
<center>
<h1> image ...</h1><br>
<h3><i> Place your mouse pointer on the picture</i></h3>
<A onMouseOver="imageSwitchOn('img1')" onMouseOut="imageSwitchOff('img1')" >
<img src="star1.jpg" height=200 width=200 alt="space" name="img1"></A>
</center>
</body>
</html>
CHANGING IMAGE SELECT THE OPTION
<html>
<head>
<title>changing image</title><script>
function imageinit()
{
img1on=new image();
img1off=new image();
img1switch=new image();
img1on.src="background.jpg";
img1off.src="creek.jpg";
img1switch.src="dock.jpg";
}
function imageswitch1(imagename)
{
image=eval(imagename+"on.src");
document[imagename].src=image;
}
function imageswitch2(imagename)
{
image=eval(imagename+"off.src");
document[imagename].src=image;
}
function imageswitch3(imagename)
{
image=eval(imagename+"switch.src");
document[imagename].src=image;
}
</script>
</head>
<body onload="imageinit()">
<center>
<h1>image...</h1>
<br>
<h3><i>click the button to view the image...</i></h3>
<img src="garden.jpg" height=200 width=200 alt="space" name="img1">
<br><br><br>
<input type="button" value="butterfly" onclick="imageswitch1('img1')">
<input type="button" value="parrots" onclick="imageswitch2('img1')">
<input type="button" value="flowers" onclick="imageswitch3('img1')">
</center>
</body>
</html>
EMPLOYEE VALIDATION FORM
<html>
<head>
<title> employee form validation </title>
<script language="vbscript">
option explicit
dim radioselected
dim i,eval
function process_order()
if len(document.myform.firstname.value) < 1 then
window.alert("you my provide your first name.")
exit function
end if
if len(document.myform.lastname.value) < 1 then
window.alert("you must provide your last name.")
exit function
end if
if len(document.myform.emailaddress.value) < 1 then
window.alert("you must provided your email address.")
exit function
end if
eval=document.myform.emailaddress.value
if instr(eval,"@")<1 or instr(eval,".")<1 then
window.alert("you must provided proper email address.")
exit function
end if
radioselected = "no"
for i = 0 to myform.myradio.length - 1
if myform.myradio(i).checked = "true" then
radioselected = "yes"
end if
next
if radioselected = "no" then
window.alert("you must select gender.")
exit function
end if
if len(document.myform.mytextarea.value) < 1 then
window.alert("you must provided your address.")
exit function
end if
if len(document.myform.phno.value) < 1 then
window.alert("you must provided your phno.")
exit function
end if
if len(document.myform.phno.value) < 10 or len(document.myform.phno.value)>10 then
window.alert("you must provided 10 digit phno.")
exit function
end if
window.alert("your registration form looks good. click on submit!")
end function
</script>
</head>
<body>
<center>
<h3>registration page for employee details</h3>
</center>
<b>please fill out the following information to register at our web site!</b>
<form name="myform" action="mailto:[email protected]" enctype="text/plain">
<b>what is your first name:</b> <input name="firstname" type="text" size="10"
maxlength="30"><p>
<b>what is your last name: </b> <input name="lastname" type="text" size="10"
maxlength="30"><p>
<b>what is your email address:</b> <input name="emailaddress" type="text" size="20"
maxlength="30"><p>
<b>select select your gender</b>
male <input name="myradio" type="radio" value="genmale">
female: <input name="myradio" type="radio" value="genfemale"><br>
address:<textarea name="mytextarea" rows="5" cols="50"></textarea><p>
phonenumber:<input name="phno" type="text" size="10" maxlength="30"><p>
<input name="myreset" type="reset" value="clear the form">
<input name="mysubmit" type="submit" value="submit your order"
onclick="window.alert('thanks for registering with our web site!')">
<input name="mybutton" type="button" value="validate your order" onclick="process_order()
">
</form>
</body>
</html>