अगर वहाँ एक सर्वर साइड सत्यापन त्रुटि है पृष्ठ के लोड होने वहाँ वर्ग 'फ़ील्ड-मान्यता-त्रुटि' के साथ किसी स्पान तत्व हो जाएगा तो हम कर सकते बस उस वर्ग के साथ सभी तत्वों से अधिक पाश , सामग्री या त्रुटि संदेश निकालें, और इसे टूलटिप में प्रदर्शित करें।
$(document).ready(function() {
// Run this function for all validation error messages
$('.field-validation-error').each(function() {
// Get the name of the element the error message is intended for
// Note: ASP.NET MVC replaces the '[', ']', and '.' characters with an
// underscore but the data-valmsg-for value will have the original characters
var inputElem = '#' + $(this).attr('data-valmsg-for').replace('.', '_').replace('[', '_').replace(']', '_');
var corners = ['left center', 'right center'];
var flipIt = $(inputElem).parents('span.right').length > 0;
// Hide the default validation error
$(this).addClass('Hidden');
// Show the validation error using qTip
$(inputElem).filter(':not(.valid)').qtip({
content: { text: $(this).text() } , // Set the content to be the error message
position: {
my: corners[flipIt ? 0 : 1],
at: corners[flipIt ? 1 : 0],
viewport: $(window)
},
show: { ready: true },
hide: false,
style: { classes: 'ui-tooltip-red' }
});
});
});
यहां एक blog post है जो बताता है कि इसे विस्तार से कैसे किया जाए।
स्रोत
2011-08-11 14:59:54