JS Programs
JS Programs
<html>
<body>
<script
type='text/javascript'>
function
textBoxValidation()
if(document.getElementById('txtBox').value.trim()== "")
blank');txtBox.focus();
return false;
sucessfully")return true;
}
</script>
<form>
</form>
</body>
</html>
Retrieve Today’s Date in JavaScript
<!DOCTYPE html>
<html>
<body>
<p id="currentDateDate"></p>
<p id="currentMonth"></p>
<p id="currentYear"></p>
<p id="currentFullDate"></p>
<p id="currentTime"></p>
<script>
</script>
</body>
</html>
<body>
<p id="pId"></p>
<script>
"Monsoon","Spring"];
document.getElementById("pId").innerHTML = season;
</script>
</body>
</html>
<html>
<body>
<p>Reverse String in
Kumar";
<p id="reverseText"></p>
<script>
) {result += str.charAt(i);
return result;
</script>
</body>
</html>
<html>
<body>
<p>In this example we can able to see how the winow.open method is used to open a new window
pagein JavaScript </p>
<script>
function openNewWindow()
window.open("https://www.google.com/);
</script>
</body>
</html>
<html>
<body>
<p><b>Here we will check how print method is work while clicking on button click<b></p>
<script>
function
PrintPage() {
window.print();
}
</script>
</body>
</html>
<html>
<body>
<p>This widow.location() method will display currently which page you are opening.</p>
<p id="pId"></p>
<script>
</script>
</body>
</html>
JavaScript Date Countdown Timer
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<p id="pId"></p>
<script>
15:37:29").getTime();var t = setInterval(function() {
"d " + hours +"h"+ minutes + "m " + seconds + "s ";if (timePeriod < 0)
{
clearInterval(t);
document.getElementById("pId").innerHTML =
"EXPIRED";
},
1000);
</script>
</body>
</html>
JavaScript screen height
<!DOCTYPE html>
<html>
<body>
<p id="pId"></p>
<script>
function showScreenHeight() {
document.getElementById("pId").innerHTML
=totalHeight;
</script>
</body>
</html>