comparison core.js @ 2044:a1574e8dfca6

Number option for survey checked to be a number. Throws an error if NaN, before would not store the response.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Thu, 18 Jun 2015 16:39:40 +0100
parents 0129f205a08d
children db70840ba8bb
comparison
equal deleted inserted replaced
2043:ccbeb4fb7315 2044:a1574e8dfca6
202 var span = document.createElement('span'); 202 var span = document.createElement('span');
203 span.textContent = node.statement; 203 span.textContent = node.statement;
204 this.popupContent.appendChild(span); 204 this.popupContent.appendChild(span);
205 this.popupContent.appendChild(document.createElement('br')); 205 this.popupContent.appendChild(document.createElement('br'));
206 var input = document.createElement('input'); 206 var input = document.createElement('input');
207 input.type = 'number'; 207 input.type = 'textarea';
208 if (node.min != null) {input.min = node.min;} 208 if (node.min != null) {input.min = node.min;}
209 if (node.max != null) {input.max = node.max;} 209 if (node.max != null) {input.max = node.max;}
210 if (node.step != null) {input.step = node.step;} 210 if (node.step != null) {input.step = node.step;}
211 this.popupContent.appendChild(input); 211 this.popupContent.appendChild(input);
212 } 212 }
296 if (node.mandatory == true && input.value.length == 0) { 296 if (node.mandatory == true && input.value.length == 0) {
297 alert('This question is mandatory. Please enter a number'); 297 alert('This question is mandatory. Please enter a number');
298 return; 298 return;
299 } 299 }
300 var enteredNumber = Number(input.value); 300 var enteredNumber = Number(input.value);
301 if (enteredNumber == undefined) { 301 if (isNaN(enteredNumber)) {
302 alert('Please enter a valid number'); 302 alert('Please enter a valid number');
303 return; 303 return;
304 } 304 }
305 if (enteredNumber < node.min && node.min != null) { 305 if (enteredNumber < node.min && node.min != null) {
306 alert('Number is below the minimum value of '+node.min); 306 alert('Number is below the minimum value of '+node.min);