sayfa yüklendiğinde sınıfında 'alan doğrulama hatası' olan bir yayılma elemanı olacak zaman bir sunucu tarafı doğrulama hatası varsa bu yüzden can bu sınıf ile tüm unsurları üzerinde sadece döngü , içeriği veya hata mesajını ayıklayın ve bir araç ipucunda görüntüleyin. İşte
$(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' }
});
});
});
ayrıntılı olarak bunun nasıl açıklayan bir
blog post olduğunu.