Improved Survey "Year Month" validation

This commit is contained in:
Patrick Donelan 2009-04-21 03:32:27 +00:00
parent a6a1cd9c07
commit 9c228e2c83
2 changed files with 4 additions and 2 deletions

View file

@ -1370,7 +1370,7 @@ section/answer.|,
},
'year' => {
message => q|Year:|,
message => q|Year (YYYY):|,
context => q|Sub-label for "Year Month" question type|,
lastUpdated => 0,
},

View file

@ -88,7 +88,9 @@ if (typeof Survey === "undefined") {
var m = document.getElementById(z1+'-month').value;
var y = document.getElementById(z1+'-year').value;
if(m == ''){ answered = 0; }
if(y.length != 4) { answered = 0; }
var yInt = parseInt(y, 10);
if(!yInt) { answered = 0; }
if(yInt < 1000 || yInt > 3000) { answered = 0; }
if(answered == 1){ document.getElementById(z1).value = m + "-" + y; }
}
}