I'm trying to customize the error messages that user's get by using the Tooltipster plugin and I run into the following problem:
You called Tooltipster's "content" method on an uninitialized element
My HTML code:
<form>
<input id="one" type="number" name="one" />
<input id="two" type="number" name="two" />
<button id="button" type="submit">Submit</button>
</form>
Javascript:
$(document).ready(function () {
$('form').validate({ // initialize the plugin
rules: {
one: {
required: true,
min: 1,
max: 100
},
two: {
required: true,
min: 50,
max: 80
}
},
submitHandler: function (form) {
doTest();
return false;
},
errorPlacement: function (error, element) {
var lastError = $(element).data('lastError'),
newError = $(error).text();
$(element).data('lastError', newError);
if (newError !== '' && newError !== lastError) {
$(element).tooltipster('content', newError);
$(element).tooltipster('show');
}
},
success: function (label, element) {
$(element).tooltipster('hide');
}
});
});
What might be the problem?