Skip to content

Commit

Permalink
Dev: Fixed issue : broken javascript if cleansedValue is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Shnoulle committed Apr 12, 2017
1 parent 6c75d58 commit a18bb1c
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions scripts/survey_runtime.js
Expand Up @@ -162,7 +162,7 @@ function checkconditions(value, name, type, evt_type)
/**
* fixnum_checkconditions : javascript function attach to some element
* Update the answer of the user to be numeric and launch checkconditions
*
*
* Also checks if any of the arrow keys is pressed to avoid unecessary hassle.
*/
function fixnum_checkconditions(value, name, type, evt_type, intonly)
Expand All @@ -183,7 +183,7 @@ function fixnum_checkconditions(value, name, type, evt_type, intonly)
* If have to use parsed value.
*/
if(!bNumRealValue)
{
{
if(checkNumericRegex.test(value)) {
try{
decimalValue = new Decimal(cleansedValue);
Expand All @@ -210,7 +210,7 @@ function fixnum_checkconditions(value, name, type, evt_type, intonly)
if(bFixNumAuto && (newval != ""))
{
var addition = "";
if(cleansedValue.split("").pop().match(/(,)|(\.)/)){
if(cleansedValue && cleansedValue.split("").pop().match(/(,)|(\.)/)){
addition = cleansedValue.split("").pop();
}
var matchFollowingZeroes = cleansedValue.match(/^-?([0-9])*(,|\.)(0+)$/);
Expand All @@ -225,7 +225,7 @@ function fixnum_checkconditions(value, name, type, evt_type, intonly)
decimalValue = new Decimal(cleansedValue.replace(',','.'));
} catch(e){
decimalValue = new Decimal(NaN);

}
}
}
Expand All @@ -247,12 +247,12 @@ function fixnum_checkconditions(value, name, type, evt_type, intonly)
if (displayVal=='NaN')
{
newval=displayVal;
displayVal=value;
displayVal=value;
}
else{
if(LEMradix==",")
displayVal = displayVal.replace(/\./,',');

newval = displayVal+addition

if (name.match(/other$/)) {
Expand All @@ -263,7 +263,7 @@ function fixnum_checkconditions(value, name, type, evt_type, intonly)

if($('#answer'+name).val() != newval){
$('#answer'+name).val(newval);
}
}
}
}

Expand Down

0 comments on commit a18bb1c

Please sign in to comment.