Skip to main content

date-month-year validation in javascript

<script>
function check()
{

   var dateCheck = /^(0?[1-9]|[12][0-9]|3[01])$/;
   var monthCheck = /^(0[1-9]|1[0-2])$/;
   var yearCheck = /^\d{4}$/;
    var  a =document.myform.date.value;
var  b=document.myform.month.value;
var c=document.myform.year.value;
if(a.match(dateCheck))
  {
    alert ("date is ok");
  }
 
  else
  {
  alert ("date is not ok");
  }
 
  if(b.match(monthCheck))
  {
    alert ("month is  ok");
  }
 
  else
  {
  alert ("month is not ok");
  }
 
  if(c.match(yearCheck))
  {
    alert ("year is  ok");
  }
 
  else
  {
  alert ("year is not ok");
  }
}
</script >

<form name=myform>
Enter Date:<input type=text name=date>
Enter Month:<input type=text name=month>
Enter year<input type=text name=year>

<INPUT name="Submit"  type="button" class="style2" onclick="javascript:check();" value="Submit">
</form>

Comments

  1. informative blog for fresher
    i must say if fresher can follow your blog so he she don't need to join any course or other institute they can learn java script from your blog
    https://sisgain.com/hire-android-developer

    ReplyDelete

Post a Comment

Popular posts from this blog

Jquery Sliding

jQuery Sliding Methods:-  With jQuery you can create a sliding effect on elements. jQuery has the following slide methods: slideDown() slideUp() slideToggle() (1)slideDown()  example:- <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){   $("#flip").click(function(){     $("#panel").slideDown("slow");   }); }); </script> <style> #panel, #flip {   padding: 5px;   text-align: center;   background-color: #e5eecc;   border: solid 1px #c3c3c3; } #panel {   padding: 50px;   display: none; } </style> </head> <body> <div id="flip">Click to slide down panel</div> <div id="panel">Hello world!</div> </body> </html> (2)sldeUP()  example:- <html> <head> <script src="https://ajax....

Juqery Event

(1)Click Event example:- ​<html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){   $("p").click(function(){     alert("The paragraph was clicked.");   }); }); </script> </head> <body> <p>Click on this paragraph.</p> </body> </html> (2)Mouseenter  Event Example  :- <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> <script> $(document).ready(function(){   $("p").mouseenter(function(){     $("p").css("background-color", "yellow");   });   $("p").mouseleave(function(){     $("p").css("background-color", "lightgray");   }); }); </script> </head> <body> <p>Move the mouse po...

XSLT QUICK GUIDE

E X tensible  S tylesheet  L anguage  T ransformation commonly known as XSLT is a way to transform the XML document into other formats such as XHTML. XSL Before learning XSLT, we should first understand XSL which stands for E X tensible  S tylesheet  L anguage. It is similar to XML as CSS is to HTML. Need for XSL In case of HTML document, tags are predefined such as table, div, and span; and the browser knows how to add style to them and display those using CSS styles. But in case of XML documents, tags are not predefined. In order to understand and style an XML document, World Wide Web Consortium (W3C) developed XSL which can act as XML based Stylesheet Language. An XSL document specifies how a browser should render an XML document. Following are the main parts of XSL − ·          XSLT  − used to transform XML document into various other types of document. ·       ...