<html>
<head>
<title> formvalidation</title>
<script type="text/javascript">
function formValidate() {
var username=document.forms["registration"]["username"].value;
var phoneno=document.forms["registration"]["phoneno"].value;
var email=document.forms[“registration”][“email”].value;
var password=document.forms["registration"]["password"].value;
if (username == "" || phoneno == "" || email==”” || password == "" ){
alert("all fields are empty");
return false;
var re=/^\d{10}$/;
if (!re.test(phoneno)){
alert("invlaid phone number");
return false;
var ra=/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (!ra.test(phoneno)){
alert("invlaid phone number");
return false;
if(password.length<6){
alert("invalid password because password must be greater than 6..");
return false;
alert("registration successfull");
return true;
}
</script>
</head>
<body>
<h1> FORM VALIDATION</h1>
<form name="registration" onsubmit="return formValidate()">
username:<input type="text" name="username"><br><br>
phoneno:<input type="number" name="phoneno"><br><br>
email:<input type=”text” name=”email”><br><br>
password:<input type="password" name="password"><br><br>
<input type="submit" value="register">
</form>
</body>
</html>
<html>
<head>
<title>Student result</title>
<script type = "text/javascript">
function findresult()
var result="";
var grade="";
var stname=document.getElementById("stname").value;
var m1=parseInt(document.getElementById("mark1").value);
var m2=parseInt(document.getElementById("mark2").value);
var m3=parseInt(document.getElementById("mark3").value);
var m4=parseInt(document.getElementById("mark4").value);
if (m1>100||m2>100||m3>100||m4>100)
alert("Marks cannot be more than 100");
return;
var total = (m1+m2+m3+m4);
avg = Math.round(total/4);
if(m1<40||m2<40||m3<40||m4<40)
result = "Fail";
else
if(avg>=80)
result="Distinction";
grade="A";
else if(avg<80 && avg>60)
result="First Division";
grade="B";
else if(avg<60 && avg>50)
result="Second Division";
grade="C";
}
else if(avg<50 && avg>40)
result="Pass Class";
grade="D";
document.writeln("<table align='center' bgcolor='yellow' height='300' width='500'>");
document.writeln("<tr><td><b><big>Student Name :</td><td>"+stname+"</td><tr>");
document.writeln("<tr><td><b><big>Total Marks :</td><td>"+total+"</td><tr></b>");
document.writeln("<tr><td><b><big>Average Marks :</td><td>"+avg+"</td><tr></b>");
document.writeln("<tr><td><b><big>Result :</td><td>"+result+"</td><tr></b>");
document.writeln("<tr><td><b><big>Grade :</td><td>"+grade+"</td><tr></b>");
</script>
</head>
<body bgcolor="pink" align="center">
<form>
<center><b><h1>Student Information</h1></b></center><br><br>
<pre><big><big>
STUDENT NAME <input type="text" id="stname"/><br>
ANALYSIS & DESIGN ALGORITHM <input type="text" id="mark1"/><br>
COMPUTER GRAPHICS <input type="text" id="mark2"/><br>
SYTEM PROGRAMING <input type="text" id="mark3"/><br>
WEB PROGMAMMING <input type="text" id="mark4"/><br>
</big></big></pre>
<input type = "button" value = "View Result" onclick="findresult()"/>
<input type = "reset" value = "RESET">
</form>
</body>
</html>
<html>
<head>
<script type = "text/javascript">
var num = window.prompt("Enter the number:","");
var n = parseInt(num);
result = sumnaturalno(n);
window.alert("The sum of " + n + "natural number is" + result);
function sumnaturalno(n)
var i;
var sum = 0;
for(i = 1;i <= n; i++){
sum = sum + i;}
return (sum);
</script>
</head>
</html>
<html>
<head>
<script type = "text/javascript">
var d = new Date();
var weekday = new
Array("Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday");
var monthname = new
Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec");
document.write(weekday[d.getDay()] + " ");
document.write(d.getDate() + ". ");
document.write(monthname[d.getMonth()] + " ");
document.write(d.getFullYear());;
</script>
</head>
<body>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title>Registration Form</title>
<script type = "text/javascript">
function calc()
var m1,m2,m3,avg = 0,total = 0, result = "",grade = "";
m1 = parseInt(document.form1.wp.value);
m2 = parseInt(document.form1.sp.value);
m3 = parseInt(document.form1.cg.value);
total = m1+m2+m3;
avg = total/3;
if( m1 < 35 || m2 < 35 || m3 < 35)
result = "fail";
grade = "D";
else if(avg >= 75)
result = "Distinction";
grade = "A+";
}
else if(avg >= 60 && avg < 75)
result = "First class";
grade = "A";
else if(avg >= 50 && avg < 60)
result = "Second class";
grade = "B";
else if(avg >=35 && avg < 50)
result = "Pass class";
grade = "C";
else if (avg < 35)
result = "Fail";
Grade = "D";
document.form1.result.value = result;
document.form1.grade.value = grade;
document.form1.total.value = total;
document.form1.average.value = avg;
</script>
</head>
<body>
<form name = "form1">
<table border = "1">
<tr>
<td> Student Name</td>
<td><input type = "text" /></td>
</tr>
<tr>
<td colspan = "2" align = "center">Subject Marks</td>
</tr>
<tr>
<td>Web Programming</td>
<td><input type = "text" name = "wp" /></td>
</tr>
<tr>
<td>Computer Graphics</td>
<td><input type = "text" name = "cg" /></td>
</tr>
<tr>
<td>System Programming</td>
<td><input type = "text" name = "sp" /></td>
</tr>
<tr>
<td colspan = "2" align = "center"><input type = "button" onclick = "calc()" value =
"calculte" /></td>
</tr>
<tr>
<td>Total</td>
<td><input type = "text" name = "total"/></td>
</tr>
<tr>
<td>Average</td>
<td><input type = "text" name = "average" /></td>
</tr>
<tr>
<td>Result</td>
<td><input type = "text" name = "result" /></td>
</tr>
<tr>
<td>Grade</td>
<td><input type = "text" name = "grade"/></td>
</tr>
</table>
</form>
</body>
</html>
<html>
<head>
<title>Registration Form</title>
<script type = "text/javascript">
function calc()
var bp,DA,HRA,GP,PF,Tax,Deduction,NetPay,name,id,desg;
name = document.form1.firstname.value;
id = document.form1.userid.value;
desg = document.form1.designation.value;
bp = parseInt(document.form1.bp.value);
DA = bp * 0.5;
HRA = bp * 0.5;
GP = bp + DA + HRA;
PF = GP * 0.02;
Tax = GP * 0.01;
Deduction = Tax + PF;
NetPay = GP - Deduction;
document.form1.da.value = DA;
document.form1.hra.value = HRA;
document.form1.gp.value = GP;
document.form1.pf.value = PF;
document.form1.tax.value = Tax;
document.form1.deduction.value = Deduction;
document.form1.netpay.value = NetPay
</script>
</head>
<body >
<form name = "form1">
<table border = "1">
<tr>
<td>Name</td>
<td><input type = "text" name = "firstname" /></td>
</tr>
<tr>
<td>User ID</td>
<td><input type = "text" name = "userid" /></td>
</tr>
<tr>
<td>Designation</td>
<td><input type = "text" name = "designation" /></td>
</tr>
<tr>
<td>Basic Pay</td>
<td><input type = "text" name = "bp"></td>
</tr>
<tr>
<td colspan = "2" align = "center">
<input type = "button" name = "calculate" value = "Click Here To Calculate"onclick
="calc()"></td>
</tr>
<tr>
<td>Dearness Allowance </td>
<td><input type = "text" name = "da"/></td>
</tr>
<tr>
<td>House Rent Allowance </td>
<td><input type = "text" name = "hra"></td>
</tr>
<tr>
<td>GP</td>
<td><input type = "text" name = "gp"></td>
</tr>
<tr>
<td>Provident Fund</td>
<td><input type = "text" name = "pf" /></td>
</tr>
<tr>
<td>Tax</td>
<td><input type = "text" name = "tax" /></td>
</tr>
<tr>
<td>Deduction</td>
<td><input type = "text" name = "deduction" /></td>
</tr>
<tr>
<td>NetPay</td>
<td><input type = "text" name = "netpay" /></td>
</tr>
</table>
</form>
</body>
</html>