Skip to content

Commit

Permalink
Text question with number input type shows error when it should not f…
Browse files Browse the repository at this point in the history
…ixed #5758 (#5760)
  • Loading branch information
andrewtelnov authored Mar 14, 2023
1 parent 14d14ee commit d3b3bfa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/question_text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -280,14 +280,14 @@ export class QuestionTextModel extends QuestionTextBase {
}
private get isValueLessMin(): boolean {
return (
!this.isValueEmpty(this.renderedMin) &&
!this.isValueEmpty(this.renderedMin) && !this.isEmpty() &&
this.getCalculatedMinMax(this.value) <
this.getCalculatedMinMax(this.renderedMin)
);
}
private get isValueGreaterMax(): boolean {
return (
!this.isValueEmpty(this.renderedMax) &&
!this.isValueEmpty(this.renderedMax) && !this.isEmpty() &&
this.getCalculatedMinMax(this.value) >
this.getCalculatedMinMax(this.renderedMax)
);
Expand Down
14 changes: 13 additions & 1 deletion tests/question_texttests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,4 +315,16 @@ QUnit.test("Test event handlers do not change question'value if newValue is same
target: testInput
});
assert.equal(log, "->changedValue", "Value should be changed only one time");
});
});
QUnit.test("min/max numeric, non required, bug#5758", function(assert) {
const survey = new SurveyModel({
elements: [{ type: "text", name: "q1", inputType: "number", min: 1, max: 10 }]
});
const q = survey.getQuestionByName("q1");
q.value = 12;
q.validate();
assert.equal(q.errors.length, 1, "There is an error");
q.value = "";
q.validate();
assert.equal(q.errors.length, 0, "There is no errors");
});

0 comments on commit d3b3bfa

Please sign in to comment.