本文实例为人人分享了Asp.net Mvc表单考证的制造代码,供人人参考,具体内容以下
将ASP.NET MVC或ASP.NET Core MVC的表单考证改成气泡提醒:
//新建一个js文件(如:jquery.validate.Bubble.js),在所有要考证的页面援用 (function ($) { $("form .field-validation-valid,form .field-validation-error") .each(function () { var tip = $(this); var fname = tip.attr("data-valmsg-for"); var input = $("#" + fname); var vgName = "vg" + fname; $("<span class='vg' id='" + vgName + "'></p>").insertBefore(input); input.appendTo("#" + vgName); tip.appendTo("#" + vgName); }); })(jQuery);
.control-label {display: block; text-align:left;} @media (min-width: 768px) { .control-label { display:inline-block;min-width:75px; text-align:right; } } .vg { display: block; position: relative; overflow: visible; } .vg .form-control{display:block;max-width:inherit;} @media (min-width: 768px) { .vg { display: inline-block; } } .vg .field-validation-error { position: absolute; bottom: 101%; min-height: 30px; z-index: 999; right: 0px; background: #ff0000; color: #FFFFFF; padding: 0px; border: 7px solid #ff0000; border-radius: 0.7em; font-size: 9pt; font-family: "Helvetica Neue", Helvetica,微软雅黑, Arial, sans-serif; max-height: 3.7em; overflow: visible; text-overflow: ellipsis; line-height: 1.3em; opacity: 0.7; } .vg .field-validation-error::after { content: " "; position: absolute; width: 1px; height: 1px; border: 14px solid blue; border-color: transparent; border-top-color: #ff0000; display: block; overflow: visible; top: 100%; right: 0px; }
//新建一个css文件(如:jquery.validate.Bubble.css),在所有要考证的页面援用
然后您的表单不用做任何修正就能够一般显现了(control-label 相干的款式能够不要(1-6行)).
以上就是Asp.net Mvc表单考证气泡提醒结果展现的细致内容,更多请关注ki4网别的相干文章!