Jump to content

Allow increase of number but not decrease


erme

Recommended Posts

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!

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.