insin / react-maskedinput

Masked <input/> React component
http://insin.github.io/react-maskedinput/
MIT License
730 stars 197 forks source link

update the pattern does not chanage the value correctly. #56

Open BesatZardosht opened 8 years ago

BesatZardosht commented 8 years ago

let't say the value is 123456 and the pattern is 111111. the input mask will show all the numbers and it works perfectly! if I change mask to 111 the input mask will show 123 which is correct. but if I change the mask back to 11111 it will show 123__ !!!!!! However the value is not changed and even I provide the correct value (123456) again but since the value has not changed it ignores it!!! you can see it here: http://insin.github.io/react-maskedinput/

I would appreciate any help

jquense commented 8 years ago

I think something is failing to note that the value has actually changed in this case...

BesatZardosht commented 8 years ago

the value has not changed. I only change the pattern, but when I change the pattern back to the original it does not update the input mask

BesatZardosht commented 8 years ago

The value is shown as "changing" variable:

screen shot 2016-06-21 at 1 59 55 pm

screen shot 2016-06-21 at 2 00 12 pm

you can see in this snapshot that the value is still 12345678 but the input mask is not showing correct value

screen shot 2016-06-21 at 2 00 22 pm

jquense commented 8 years ago

the value changes, when the new mask causes the value to be truncated, does amount to a change in the underlying value, masks specifically exist to place hard requirement on the shape of the value, so it wouldn't make sense to allow the value to be something non-conforming to its mask.

In my opinion the bug here is that the input mistakenly thinks the value didn't change and so you cannot reset it to the original one.

BesatZardosht commented 8 years ago

Could be! thanks! the weird thing is it is returning same value for getRawValue and getValue!! and both are the display value

nurulc commented 8 years ago

Check this out, it may help you with your requirements: RxInput demo

You may remember I mentioned earlier I was working on a version of maskeinput that uses regular expressions to define the mask and matching rules. I have not figured out if it is possible to use the normal regular expression matcher to do this. I actually do not think so. I implement a version of incremental (match as you type) regular expression.

nurulc commented 8 years ago

Hi,

If you need flexible pattern, try react-rxinput demo

int the first input box ( label: Enter a Regular expression: where you can enter your own regular expression)

Tab to the next input box (label: Regex Tester:) you can try out how the regular expression you entered affects the mask and what you can type. Note: you will also see a suggestion box.

The demo page has a a few sample regular expression you can try.