Improved Survey "Year Month" validation
This commit is contained in:
parent
a6a1cd9c07
commit
9c228e2c83
2 changed files with 4 additions and 2 deletions
|
|
@ -1370,7 +1370,7 @@ section/answer.|,
|
||||||
},
|
},
|
||||||
|
|
||||||
'year' => {
|
'year' => {
|
||||||
message => q|Year:|,
|
message => q|Year (YYYY):|,
|
||||||
context => q|Sub-label for "Year Month" question type|,
|
context => q|Sub-label for "Year Month" question type|,
|
||||||
lastUpdated => 0,
|
lastUpdated => 0,
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,9 @@ if (typeof Survey === "undefined") {
|
||||||
var m = document.getElementById(z1+'-month').value;
|
var m = document.getElementById(z1+'-month').value;
|
||||||
var y = document.getElementById(z1+'-year').value;
|
var y = document.getElementById(z1+'-year').value;
|
||||||
if(m == ''){ answered = 0; }
|
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; }
|
if(answered == 1){ document.getElementById(z1).value = m + "-" + y; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue