I have the following script to check if a date is valid:
var text = '2/31/2013'; 
var comp = text.split('/'); 
var m = parseInt(comp[0], 10); 
var d = parseInt(comp[1], 10); 
var y = parseInt(comp[2], 10); 
var date = new Date(y,m-1,d); 
if(date.getFullYear() == y && date.getMonth() + 1 == m && date.getDate() == d) {
    console.log('Valid date'); 
}
else {
    console.log('Invalid date');
    var NextValidDate = new Date(y,m-1,d+1);
    console.log(NextValidDate);    
}
I would like to jump now to the next correct date. In the sample case is this the 01. March 2012.
But how to get it? NextValidDate gives not always a correct date.
 
     
     
    