Skip to content

Commit

Permalink
fix: input range validator
Browse files Browse the repository at this point in the history
  • Loading branch information
unocelli committed May 21, 2024
1 parent 029a99c commit 172665a
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,12 @@ export class HtmlInputComponent extends GaugeBaseComponent {
HtmlInputComponent.checkInputType(input, gab.property.options);
input.setAttribute('autocomplete', 'off');
if (gab.property.options) {
if (gab.property.options.numeric) {
if (gab.property.options.numeric || gab.property.options.type === InputOptionType.number) {
const min = parseFloat(gab.property.options.min);
const max = parseFloat(gab.property.options.max);
input.addEventListener('keydown', (event: KeyboardEvent) => {
try {
if (event.code === 'Enter' && !event.view) {
if (event.code === 'Enter' || event.code === 'NumpadEnter') {
const value = parseFloat(input.value);
let warningMessage = '';
if (min > value) {
Expand Down Expand Up @@ -318,7 +318,7 @@ export class HtmlInputComponent extends GaugeBaseComponent {
min: 0,
max: 0
};
if (ga.property?.options?.numeric || ga.property?.options?.number === InputOptionType.number){
if (ga.property?.options?.numeric || ga.property?.options?.type === InputOptionType.number){
if(!Utils.isNullOrUndefined(ga.property.options.min) && !Utils.isNullOrUndefined(ga.property.options.max)){
if(Number.isNaN(value) || !(/^-?[\d.]+$/.test(value))){
return {
Expand Down

0 comments on commit 172665a

Please sign in to comment.