前端验证与其它常用组件说明

创建时间: 2011年5月13日

JS验证框架

  • 针对from中的所需要验证数据元素加上vtype属性指明验证的类型,同一元素验证多个类型则需用&&符号间隔开.
<input type="text"  vtype="email" size="20" name="contact[email]" class="x-input " />

<input type="text"  vtype="required&&email" size="20" name="contact[email]" class="x-input " />
  • 后台框架默认的vtype验证类型有限,如无法满足需求可自定义vtype类型,如:
    <script>
    validatorMap.set('baguo', ['<{t}>字数应该在5-200个字之内<{/t}>', function(element, v) {
    	//参数说明 element是vtype为sendcomments的元素,v为此元素对应的值
    	if ($(element).getValue() == '' || $(element).getValue().length < 5 || $(element).getValue().length >= 200){
    	    return false;
    	}else{
    	    return true;
    	}
    }]);
    </script>
    

    自定义验证的运用如:

    <input vtype="baguo" name="goods_text"/>
    

Autocompleter组件自动搜索

Input中包括autocompleter属性,此属性冒号前的字符与app下php的model对应,冒号后第一个字符指明要搜索显示的字段,ac_options属性指明Autocompleter类中所需要的额外js参数(无特殊需求可不指明).

<input type="text" vtype="text" ac_options="{relative:false}" autocompleter="b2c_autocomplete_member:login_name" name="order" autocomplete="off">

Dialog

  • 弹出框基本使用.
new Dialog(url,{width:222,height:400,onShow:function(){});

在Dialog中装提交按钮固定在最底部,用<{area}>标签包住html标签指定插入到元素位置。

<{area inject='.mainFoot'}><button >提交</button><{/area}>

內容目录

上一个主题

AJAX框架Wpage运用

下一个主题

smart标签常用组件说明

快速搜索

输入相关的模块,术语,类或者函数名称进行搜索