jQuery UI Widgets › Forums › Grid › Using Grid for Data Entry – Limit Length of Text
This topic contains 7 replies, has 2 voices, and was last updated by shimmoril 11 years, 2 months ago.
-
Author
-
We’re using a grid for data entry and need to limit the length of text entered in to a cell. For example, the Name column in our DB is a varchar(100), so we’d like to prevent users from entering more than 100 characters into the grid for that column (like the maxlength property on an input field).
Is this possible, and if yes, how?
Hello shimmoril,
You can achieve this with the validation callback function, e.g.:
columns: [ { text: 'Name', columntype: 'textbox', datafield: 'Name', validation: function (cell, value) { if (value.length > 100) { return { result: false, message: "Maximum characters allowed: 100" } }; return true; } },
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/That looks great, thanks Dimitar.
Is there any way to have the error auto-dismiss after the text has been corrected? For instance, if I type 101 characters into the field, it give an error. So then I delete 2 or 3 characters (bringing me below the limit), but the error is still visible, and I have to click on it to dismiss it before I can continue working.
Hi shimmoril,
To close the validation pop-up after correcting the value, either click outside the cell or press the Enter key.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Yes, I am aware of how to close the popup. My issue is that the error message has to be manually dismissed, which interrupts the workflow. If the cell is no longer failing validation, it should remove the error automatically.
Hi shimmoril,
Unfortunately, this cannot be achieved. Validation happens only when you are about to exit edit mode.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Alright, thanks Dimitar.
-
AuthorPosts
You must be logged in to reply to this topic.