Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InputNumber? #49

Closed
awesomebytes opened this issue Nov 5, 2015 · 3 comments
Closed

InputNumber? #49

awesomebytes opened this issue Nov 5, 2015 · 3 comments

Comments

@awesomebytes
Copy link
Collaborator

Would it be possible to have an input supporting only numbers?
I can write letters in the actual SpinBox :S.

Maybe able to choose between Integer and some decimal point representation?

@dddomodossola
Copy link
Collaborator

Hi awesomebytes, SpinBox should work fine on new browsers supporting HTML5.
On browsers where this does not work, you can eventually use a trick like this:
myspinbox.attributes[myspinbox.EVENT_ONKEYPRESS] = 'return event.charCode >= 48 && event.charCode <= 57'
I prefer to not include internally these tricks in the library in order to avoid dirty code...

@awesomebytes
Copy link
Collaborator Author

Tried it, works! thank you! :)

@awesomebytes
Copy link
Collaborator Author

I improved it with:

'return event.charCode >= 48 && event.charCode <= 57 || event.charCode == 46 || event.charCode == 13'

Now it accepts "." for floating point and also hitting Enter to set the value.

dddomodossola added a commit that referenced this issue Nov 26, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants