Skip to content
Browse files

form验证错误提示添加关闭按钮

  • Loading branch information...
1 parent b0567b9 commit c1e9346e8ee49541188a91c230c9a3d6dd86e840 @q13 committed
Showing with 12 additions and 3 deletions.
  1. +12 −3 ya/lib/uihelper.js
View
15 ya/lib/uihelper.js
@@ -105,16 +105,25 @@
}
return function(v){
var validV,
- validMsgJq=elJq.data('validmsg');
+ validMsgJq=elJq.data('validmsg'),
+ validMsgContentJq;
v=$.trim(v); //v trim过滤
if(!validMsgJq){
validMsgJq=$('<div class="ui-form-field-message"></div>').insertAfter(elJq);
+ validMsgContentJq=$('<span class="message-content"></span>').appendTo(validMsgJq);
elJq.data('validmsg',validMsgJq);
+ //关闭按钮
+ $('<span class="ui-form-field-message-close">&#10005</span>').click(function(){
+ $(this).closest('.ui-form-field-message').hide();
+ return false;
+ }).appendTo(validMsgJq);
}
- validMsgJq.removeClass('ui-state-error').empty();
+ validMsgJq.removeClass('ui-state-error');
+ validMsgContentJq.empty();
validV=validateFn.apply(ui,[v,opts]);
if(!validV&&errorMsg){ //如果未通过验证并且有错误信息
- validMsgJq.addClass('ui-state-error').html(errorMsg);
+ validMsgJq.addClass('ui-state-error');
+ validMsgContentJq.html(errorMsg);
}
return validV;
};

0 comments on commit c1e9346

Please sign in to comment.
Something went wrong with that request. Please try again.