diff --git a/app/client/src/widgets/InputWidget.tsx b/app/client/src/widgets/InputWidget.tsx index 05d791fcc6..9fbd074f33 100644 --- a/app/client/src/widgets/InputWidget.tsx +++ b/app/client/src/widgets/InputWidget.tsx @@ -61,12 +61,15 @@ class InputWidget extends BaseWidget { return { isValid: `{{ function(){ - const isEmailType = this.inputType === "EMAIL"; - if(isEmailType) { + if (this.inputType === "EMAIL") { const emailRegex = new RegExp(/^\\w+([\\.-]?\\w+)*@\\w+([\\.-]?\\w+)*(\\.\\w{2,3})+$/); return emailRegex.test(this.text); - } else if(this.isRequired) { - if(this.text && this.text.length > 0) { + } + else if (this.inputType === "NUMBER") { + return !isNaN(this.text) + } + else if (this.isRequired) { + if(this.text && this.text.length) { if(this.regex) { return new RegExp(this.regex).test(this.text) } else { @@ -75,7 +78,7 @@ class InputWidget extends BaseWidget { } else { return false; } - } if(this.regex) { + } if (this.regex) { return new RegExp(this.regex).test(this.text) } else { return true;