hxppb
- hxppb 回复了话题 CActiveForm验证的问题
附上文档说明
afterValidateAttribute: function, the function that will be invoked after performing ajax-based validation triggered by a single attribute input change. The expected function signature should be afterValidateAttribute(form, attribute, data, hasError) {...}, where 'form' is the jquery representation of the form object; 'attribute' refers to the js options for the triggering attribute (see error); 'data' is the JSON response from the server-side validation; 'hasError' is a boolean value indicating whether there is any validation error. Note that because this option refers to a js function, you should wrap the value with CJavaScriptExpressoin to prevent it from being encoded as a string. This option has been available since version 1.1.3.
- hxppb 回复了话题 CActiveForm验证的问题
同时附上一篇老外的文章
http://www.yiiframework.com/forum/index.php/topic/35701-displaying-success-messages-in-cactiveform/page__p__171582__hl__cactiveform#entry171582
跳过前面所有内容,直接看如下部分'clientOptions'=>array('afterValidateAttribute'=>new CJavaScriptExpression("function(form, attribute, data, hasError){ var id=attribute.id; var eid=attribute.errorID; if(data[id].toString().substring(0,7)=='Success') { $('#'+eid+'.flash-error').css('display','none'); $('#'+id).parent().children('label.required').css('color','green'); $('#'+id).css('background','#E6EFC2'); } else { $('#'+eid+'.flash-success').css('display','none'); $('#'+id).parent().children('label.required').css('color','red'); $('#'+id).css('background','').addClass('error'); } }")), ));
- hxppb 回复了话题 CActiveForm验证的问题
这个给力,可以解决问题
- hxppb 回复了话题 CActiveForm验证的问题
问题一:比如现在验证报错了,会显示一个提示框,这个没有问题。但是我输入正确后,报错那个层就会display:none, 但是我具体的需求是不隐藏,而且显示一个绿色的小勾。
问题二:我在用户输入任何信息前会有提示语,怎么在报错的时候把这个提示语隐藏呢?因为在用户输入前报错的那个层也是隐藏的,有错误才会显现。所以感觉应该不能用同一个层。 - hxppb 回复了话题 CActiveForm验证的问题
没验证通过显示图片可以通过css来控制,但是验证前显示提示语,验证错误后把提示语用错误代替,然后验证通过后显示绿色小勾这个现在不知怎么处理。
- hxppb 回复了话题 CActiveForm验证的问题
请小龙给出具体是用什么方法或者属性。因为就像前面我提到过的正常的验证这个是没问题。能够实现。
关键是我在验证前有提示语,验证通过后要显示一个绿色的小勾。 - hxppb 发布了话题CActiveForm验证的问题
本帖隐藏的内容需要回复才可以浏览
- hxppb 回复了话题 Yii Framework视频教程第三讲(上)
继续支持
- hxppb 回复了话题 Yii Framework视频教程第二讲
支持支持