Jump to content

Allow increase of number but not decrease


Go to solution Solved by fastsol,

Recommended Posts

  • Solution

This is a working example, there are a couple ways you could tweak this depending on your needs.

http://jsfiddle.net/fastsol/6nXxe/1/

I wanted to do the check on keyup but then you couldn't even change the last number cause it would obviously be less than the 1.55, so went with focusout instead.

I assume that this input field eventually comes with some kind of submit button.. alternatively you could validate it onclick or onsubmit.

 

However, just want to point out that seeing as how this is javascript, the user can simply disable javascript or overwrite your js function to do whatever the hell he wants.. you should be validating this server-side.

This is a working example, there are a couple ways you could tweak this depending on your needs.

http://jsfiddle.net/fastsol/6nXxe/1/

I wanted to do the check on keyup but then you couldn't even change the last number cause it would obviously be less than the 1.55, so went with focusout instead.

 

Perfect, however is there an obvious reason why it wouldn't work in IE?

 

Actually it does. I'm just being stupid!

Edited by erme
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.