Preliminary check in for new Survey text number type and validation.

This commit is contained in:
Kaleb Murphy 2009-04-17 17:08:42 +00:00
parent fa2768ea50
commit caffe2751a
3 changed files with 22 additions and 1 deletions

View file

@ -1313,7 +1313,7 @@ sub prepareShowSurveyTemplate {
# 'Security', 1
# );
my %textArea = ( 'TextArea', 1 );
my %text = ( 'Text', 1, 'Email', 1, 'Phone Number', 1, 'Text Date', 1, 'Currency', 1 );
my %text = ( 'Text', 1, 'Email', 1, 'Phone Number', 1, 'Text Date', 1, 'Currency', 1, 'Number', 1 );
my %slider = ( 'Slider', 1, 'Dual Slider - Range', 1, 'Multi Slider - Allocate', 1 );
my %dateType = ( 'Date', 1, 'Date Range', 1 );
my %dateShort = ( 'Year Month', 1 );

View file

@ -117,6 +117,7 @@ sub loadTypes {
'Slider',
'Currency',
'Email',
'Number',
'Phone Number',
'Text',
'Text Date',

View file

@ -18,6 +18,9 @@ if (typeof Survey === "undefined") {
'Currency': 1,
'TextArea': 1
};
var NUMBER_TYPES = {
'Number':1
};
var SLIDER_TYPES = {
'Slider': 1,
'Dual Slider - Range': 1,
@ -65,6 +68,17 @@ if (typeof Survey === "undefined") {
alert("Please allocate the remaining " + amountLeft + ".");
}
}
else if (toValidate[i].type === 'Number') {
answered = 1;
for (var z1 in toValidate[i].answers) {
var m = document.getElementById(z1).value;
var ansValues = toValidate[i].answers[z1];
if(m > ansValues.max || m < ansValues.min || m % ansValues.step != 0){
answered = 0;
break;
}
}
}
else if (toValidate[i].type === 'Year Month') {
answered = 1;//set to true, then let a single failure set it back to false.
for (var z1 in toValidate[i].answers) {
@ -607,6 +621,12 @@ if (typeof Survey === "undefined") {
}
continue;
}
if (NUMBER_TYPES[q.questionType]) {
if (toValidate[q.id]) {
toValidate[q.id].answers[q.answers[x].id] = {'min':q.answers[x].min,'max':q.answers[x].max,'step':q.answers[x].step};
}
continue;
}
// Must be a multi-choice bundle
var butts = [];