修改了wecenter花哨的表单验证提示后如下
现在的问题是任意项报错has-error再修正后依然无法改变状态,也就是表单失去焦点不重新验证添加has-success,其中if ($(this).attr('tips') != '') {这if貌似多于,求修正方法,先谢过!
简单的说假如首次输入名字不符合规则表单class添加has-error警示,用户修改正解后依然不改变表单红色边框!
源码
verify_register_form('#register_form');
/* 注册页面验证 */
function verify_register_form(element)
{
$(element).find('[type=text], [type=password]').on({
focus : function()
{
if (typeof $(this).attr('tips') != 'undefined' && $(this).attr('tips') != '')
{
$(this).parent().append('' + $(this).attr('tips') + '');
}
},
blur : function()
{
if ($(this).attr('tips') != '')
{
switch ($(this).attr('name'))
{
case 'user_name' :
var _this = $(this);
$(this).parent().find('.aw-reg-tips').detach();
if ($(this).val().length >= 0 && $(this).val().length < 2)
{
$(this).parent().find('.aw-reg-tips').detach();
$(this).parent().append('' + $(this).attr('errortips') + '');
return;
}
if ($(this).val().length > 17)
{
$(this).parent().find('.aw-reg-tips').detach();
$(this).parent().append('' + $(this).attr('errortips') + '');
return;
}
else
{
$.post(G_BASE_URL + '/account/ajax/check_username/',
{
username: $(this).val()
}, function (result)
{
if (result.errno == -1)
{
_this.parent().find('.aw-reg-tips').detach();
_this.parent().append('' + result.err + '');
}
else
{
_this.parent().find('.aw-reg-tips').detach();
_this.parent().append('');
}
}, 'json');
}
return;
}
}
}
});
}
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
自己琢磨.removeClass('has-error') 搞掂。