jQWidgets Forums
jQuery UI Widgets › Forums › Plugins › Validator, Drag & Drop, Sortable › Extend Rule hintRender?
Tagged: extend, hintRender, jqxvalidator, rules, validate, validator
This topic contains 8 replies, has 2 voices, and was last updated by Dimitar 11 years, 5 months ago.
-
AuthorExtend Rule hintRender? Posts
-
Is there a way to extend the default rule hintRender? I want to be able to use what is already there but slightly change it.
Hello mikemazz,
Please check out the forum topic hintRender Validator for more information on hintRender.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Dimitar,
I’m not looking for a replacement but rather how to extend the current hintRender. Is that possible?
– Mike
When creating a customer hintRender like so:
var render = function (message, input) { }
I’m assuming that message is the message to display that is specified in the rule and input is the text that was typed into the input. Is that correct?
Thanks
– MikeHi Mike,
The message parameter shows the message to be displayed and input is a jQuery selection of the validated input.
As for your previous question, it is not possible to extend the hintRender function.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/I’ve been trying to write a customer hintRender with little success. The hintRender example seems to work but mine does not.
Can you tell me when the hintRender: render function is fired?
Thanks
MikeHi Mike,
The hintRender function is fired when the validation message is shown.
Best Regards,
DimitarjQWidgets team
http://www.jqwidgets.com/Dimitar,
So can you help me understand how the hint is removed one the field passes validation? I’ve written a customer hint render and it changes the color of the label underneath the field that fails validation. However, I cannot seem to properly set the color back once the field becomes valid. Here is my code:
var that = this; var render = function (message, input) { console.log("render function called"); var ne = input.next(); var clss = ne.attr('class'); if (that._message) { console.log("_message is: " + that._message.text()); if (typeof clss !== 'undefined' && clss != '' && clss.indexOf('field-caption') > -1) { console.log("Should remove hint now"); ne.attr('class', 'field-caption'); } that._message.remove(); } if (typeof clss !== 'undefined' && clss != '' && clss.indexOf('field-caption') > -1) { if (clss.indexOf('validationFailed') < 0) { var clazz=ne.attr('class'); ne.attr('class', clazz + " validationFailed"); } } else { that._message = $("<label class='validationFailed'>" + message + "</label>"); that._message.appendTo(input.parent()); } return that._message; }
Hi Mike,
The hintRender callback function is used only for formatting the validation message (hint) itself. Other scenarios are not supported.
Please consider using the “label” hintType, showcased in the demo Error Labels instead.
-
AuthorPosts
You must be logged in to reply to this topic.