JavaScript

Showing posts with label date validation. Show all posts
Showing posts with label date validation. Show all posts

Monday, 16 April 2012

How to validate date through Jquery






Submit



date validation through jquery......................


$("#Text3").datepicker({numberOfMonths:2,
     showButtonPanel: true,
     dateFormat:'dd/mm/yy',
     autoSize: true,
    
     maxDate: '+3m',
     Image:"image.axd.jpeg",
     showOn: 'both'
    
  
     });
     $("#button").click(function(){
     //alert("hello");
     var dateformat= document.getElementById("Text3");
     var splitvaue= dateformat.value.split('/');
    
     var date= new Date();
     alert(date.getMonth()+1);
    
    // if((parseInt(splitvaue[0])>=date.getDate())&&(parseInt(splitvaue[1]))>=(date.getMonth()+1)){
if(parseInt(splitvaue[1])<13 && parseInt(splitvaue[0])<=31){
    if(parseInt(splitvaue[2])==(date.getFullYear())) {
        alert("hello");
     }
}
     else
     {
     alert("should be enter Today Date");
     }
   
         });
     });


Monday, 6 February 2012

how to validate date in dd/mmm/yyyy format

this is simple validation in date format

function a(){
var i=document.getElementById("t1").value;

if(abc(i)){
alert("valid")}
else
{
alert("not valid");
}
}
function abc(output){
var i=output;
var reg= new RegExp("^([0][1-9]|[1-2][0-9]|[3][0-1])/(jan|JAN|Jan|feb|Feb|FEB|mar|Mar|MAR|apr|Apr|APR|may|May|MAY|May|Jun|jun|JUN|jul|JUL|Aug|aug|AUG|Sep|sep|SEP|Oct|oct|OCT|nov|Nov|NOV|dec|DEC|Dec)/([1-9][0-9][0-9][0-9])");
//document.write(i);
return reg.test(i);
//if(i=="")
//alert("blank");
}
 </script>