uhlryk / angular-dynamic-number

Highly customizable angular directive for numbers
64 stars 32 forks source link

Allow only positive numbers #27

Closed elieobeid7 closed 8 years ago

elieobeid7 commented 8 years ago

How to allow only positive numbers? I'm using angular 1.x and there's seem to be a bug or please show a working example. Users shouldn't be able to enter negative numbers.

uhlryk commented 8 years ago

Please write how your directive looks like (what options you set). And additional info which are necessary to reproduce bug.

elieobeid7 commented 8 years ago

@uhlryk

By modifying the "Number may be only negative, decimal separator dot" example to only accept positive number (so rename num-pos attribute to num-neg), you will see that the input behaves incorrectly whenever you type the negative sign first:

• It allows the sign symbol (-) to be typed (it has to be the first character typed) • Then if you type a a digit, it deletes the sign symbol however it converts it to 0 and loose the digit you typed • If you continue to type a second digit it is correctly taken into account • If you only type in the sign symbol (-) the model is set to 0 • The behavior is correct if you don't type the sign symbol as the very first character

save this .html file and see, i cant share it here

http://pastebin.com/zTTCB33u

uhlryk commented 8 years ago

thank you very much for your feedback. Yes it is bug. It should be fixed now. Please check if now it is better

uhlryk commented 8 years ago

It is also in examples (8th input)

elieobeid7 commented 8 years ago

will check on monday and let you know, tuesday max. thank you!

elieobeid7 commented 8 years ago

Issue solved, you may close the ticket, thanks for your help