Java Script Date Object Created with the new Date( ) Methods allow you to get and set the year, month, day, hour, minute, second, and millisecond fields of the object constructor new Date( ) new Date(milliseconds) new Date(datestring) new Date(year,month,date[,hour,minute,second,millisecond ])
JavaScript Form Validation validate the form submitted by the user because it can have inappropriate values can validate name, password, email, date, mobile number etc fields provides you the facility the validate the form on the client side so processing will be fast than server-side validation
Date Objects <html> <body> current time: <p id="time"></p> <script> window.onload=function(){gettime();} function gettime() { var a=new Date(); var h=a.getHours(); var m=a.getMinutes(); var s=a.getSeconds(); m=checktime(m); s=checktime(s); document.getElementById("time").innerHTML=h+":"+m+":"+s; setTimeout(function(){gettime()},1000); } function checktime(i) { if(i<10) i="0"+i; return i; </script> </body> </html>
JavaScript-Regular Expression A regular expression is an object that describes a pattern of characters. used to perform pattern-matching and "search-and-replace" functions on text Syntax /pattern/modifiers; Example var patt = /w3schools/i /w3schools/i is a regular expression. w3schools is a pattern (to be used in a search). i is a modifier (modifies the search to be case-insensitive).
Modifiers perform case-insensitive and global searches Modifier Description i Perform case-insensitive matching g Perform a global match (find all matches rather than stopping after the first match) m Perform multiline matching Brackets used to find a range of characters
Metacharacters
<html> <body> <p>Click the button to do a global search for word characters in a string.</p> <button onclick="myFunction()">Try it</button> <p id="demo"></p> <script> function myFunction() { var str = "Give 100%!"; var patt1 = /\w/g; var result = str.match(patt1); document.getElementById("demo").innerHTML = result; } </script> </body> </html>