Semantic-ui: [Form Validation] not working for number inputs

Created on 7 Jul 2017  路  10Comments  路  Source: Semantic-Org/Semantic-UI

I'm using semantic ui form validation in one of my projects in ember. The validation does not work for number type input.

Code Snippet:

level: {
          identifier : 'level',
          optional   : true,
          rules      : [
            {
              type   : 'integer',
              prompt : this.l10n.t('Please enter a number')
            }
          ]
        }

Template

{{input type='number' value=sponsor.level name='level' min=0}}

Note: Validation works if I remove optional: true

Please guide. Thanks

Confirmed Bug stale

Most helpful comment

@geekyd Thank you, confirming the issue. It seems that you either have to set optional to false, or use the text type instead of the number.

All 10 comments

Hi @geekyd, I鈥檝e just tested it, it works. Can you please elaborate, what did you mean when you said that it didn鈥檛 work, what happened exactly? Any console errors?

There are no console errors.
I'm able to enter e as input and its getting validated as an integer. It should prompt an error if e is present in the input. It seems to work if we remove optional.

@geekyd Alright, unfortunately, we can鈥檛 investigate it further if we can鈥檛 reproduce it in an isolated test case without Ember. I might鈥檝e missed something when tested it, so please fork this JSFiddle and see if you can reproduce it there.

@Banandrew The Validation works for

<div class="field">
  <label class="required">Level</label>
  {{input type='number' value=sponsor.level name='level'}}
</div>

However the validation does not work for the nested fields.

<div class="fields">
<div class="two wide field">
  <label class="required">Level</label>
  {{input type='number' value=sponsor.level name='level'}}
</div>
</div>

Is it a known issue?

@geekyd Seems to be working fine: https://jsfiddle.net/Banandrew/3fwy7na6/

@Banandrew Please check https://jsfiddle.net/geekyd/7kwehhk7
Try non integer inputs eg. e
Thanks

@geekyd It鈥檚 the same JSFiddle that I posted.

@Banandrew Sorry about that, please check https://jsfiddle.net/geekyd/a2ktp4ap/

@geekyd Thank you, confirming the issue. It seems that you either have to set optional to false, or use the text type instead of the number.

There has been no activity in this thread for 90 days. While we care about every issue and we鈥檇 love to see this fixed, the core team鈥檚 time is limited so we have to focus our attention on the issues that are most pressing. Therefore, we will likely not be able to get to this one.

However, PRs for this issue will of course be accepted and welcome!

If there is no more activity in the next 90 days, this issue will be closed automatically for housekeeping. To prevent this, simply leave a reply here. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

playgithub picture playgithub  路  3Comments

kntmrkm picture kntmrkm  路  3Comments

Morrolan picture Morrolan  路  3Comments

zhaoyao91 picture zhaoyao91  路  3Comments

mixerp picture mixerp  路  3Comments