jQuery UI Widgets › Forums › Grid › Vaidation on number column
Tagged: columntype, invalid string, jqxgrid, numberinput
This topic contains 12 replies, has 2 voices, and was last updated by ivailo 9 years, 4 months ago.
-
Author
-
Hi all,
I have an editable grid with a number column.
When the user enters an invalid string instead of a number, the string is converted to 0 and no error is given to the user.
So the user might accidently enter and save the incorrect value 0.
The validation callback already has the new value of 0 , so I cannot react correctly there.
I also cannot use the geteditorvalue function, because I am using a different localisation which is not yet interpreted in geteditorvalue.So how can I either prevent the change to 0 or give a valid error message?
Thanks in advance
Hi flehmann,
You can set
columntype: 'numberinput'
. This will prevent entering of any incorrect string values.Look at this fiddle.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comThanks,
The customer really dislikes the numberinput control.
Also the number of decimals varies from time to time so that is not an option.
Any other possibility?Hi flehmann,
You can customize the numberinput control with createeditor function, so the customer “do not feels it like a numberinput”.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHow can I set the numberinput to allow any number of decimals?
Hi flehmann,
You can use
decimalDigits
property about these purposes.
Here is a fiddle.Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi Ivailo,
Thanks for your reply, but I was asking about ANY number of decimals.
The customer does not want to be restricted to 2 or 4 or whatever number.
He just wants to be able to enter any number with any decimals. But he also needs a validation error in case he does enter an invalid string.
And converting data to 0 without further notification is a big no-go that really alerted many people.Thanks for your help.
Hi flehmann,
In this case the solution is to use regular input plus regex validation.
Here is the fiddle.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comThat sounds promising, but when I use this combined with localization (german) it gets really crazy:
http://jsfiddle.net/h2kkh438/1/
Now when I can enter neither “12,3” nor “12.3”
It seems the validation method still uses the english input, but afterwards there is some other kind of validation that leads to the error “Entered value is not valid” which is not the error message we defined.Any help on that?
Hi flehmann,
When you have to change the localization, you must set the regex for the allowed symbols.
Also in this case to use toString method to convert the value.Here is the fiddle.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.comHi,
We are getting close, but still…
Now the basic validation (remember, thats what it is all about) is not working anymore.
I can enter “asd” it gets converted to “0” and I wont have any validation for it.I am really sorry, but thats what I am fighting with for days…
Hi Ivailo,
Any news on this issue?
Hi flehmann,
Unfortunately there is no option for covering all requirements that you have.
Best Regards,
Ivailo IvanovjQWidgets Team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.