Está en la página 1de 2

<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>
Copy Text JavaScript Program (for beginners)
This is simple JavaScript Program with example to Copy Text from Different Field
.
<html>
<head>
<title>
Copy text</title>
</head>
<body>
<center>
<h2>Copy text from different field</h2>
<p>
<input type="text" style="color: #FF0080;background-color: #C9C299" id="field1"
value="Good Morning">
<input type="text" style="color: #FF0080;background-color: #C9C299" id="field2">
<button style="background-color: #E799A3" onclick="document.getElementById('fiel
d2').value = document.getElementById('field1').value">Click to Copy Text
</p>
</center>
</body>
</html>
Form Validation JavaScript Program (for beginners)
This is a simple JavaScript form validation program with example.
Form Validation Centers Button Style Cols Either
<html>
<head>
<script type="text/javascript">
function sub()
{
if(document.getElementById("t1").value == "")
alert("Please enter your name");
else if(document.getElementById("t2").value == "")
alert("Please enter a password");
else if(document.getElementById("t2").value != document.getElementById("t3").val
ue)
alert("Please enter correct password");
else if(document.getElementById("t4").value == "")
alert("Please enter your address");
else
alert("Form has been submitted");

}
</script>
</head>
<body>
<form>
<p align="center">
User Name:<input type="text" id="t1"><br><br>
Password:<input type="text" id="t2"><br><br>
Confirm Password:<input type="text" id="t3"><br><br>
Address:<textarea rows="2" cols="25" id="t4"></textarea><br><br>
<input type="button" value="Submit" onclick="sub()">
<input type="reset" value="Clear All">
</p>
</form>
</body>
</html>

También podría gustarte