JavaScript Program

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('field2').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.


  • Colors
  • Resume Format
  • Reverse address lookup
  • Your Name
<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").value)
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>




Best Of Luck

Comments

Popular posts from this blog

A Javascript Program To make (open new window and close that window) button in your web browser.

A simple running clock in javascript