在Ext Js VType中使用正则表达式 [英] Using regular expression in Ext Js VType

查看:174
本文介绍了在Ext Js VType中使用正则表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  var regex = / ^ \d + -\d {1,2} $ /; //检查数位数(s,1或2)

文本域。但是如果我想要一个Ext Js TextField,我必须执行以下代码



Ext js TextField并调用一个VType

  var< portlet:namespace /> issueNoField = new Ext.form.TextField({
fieldLabel:'Issue No',
width:120,
valueField:'IssNo',
vtype:'hyphen'
});

Ext.apply(Ext.form.VTypes,{
hyphenText:只有数字和连字符,
hyphenMask:/ [0-9 - ] /,
hyphenRe:/ ^ \d + -\d {1,2} $ /,//这是支票
连字号:function(x){return this.hyphenRe.test(x);} / /我错过了一个numericHyMask:here?
});

是hyphenRe:/ ^ \d + -\d {1,2} $ /,是正确的或
是连字符号:/ ^ \d + - [\d {1 ,2}] $ /,是正确的,因为我想要1到2位数字后' - '

请帮助我改变我的VTypes正常工作,并进行正则表达式检查。

解决方案

验证本身不工作(当您在其中输入无效内容时,该字段不会被下划线)或者您是否缺少错误 - 工具提示?在后一种情况下,添加到代码中的某个地方:

  Ext.QuickTips.init(); 

否则,工具提示不会出现。


I have a regular expression for checking numbers and allowing "-" (Hyphen) Text Field.

var regex = /^\d+-\d{1,2}$/;  //Checks "digits-digit(s,1 or 2)"

This works ok for regular HTML text field. But if I want a Ext Js TextField I have to do the below code

Ext js TextField and called a VType

var <portlet:namespace/>issueNoField = new Ext.form.TextField({
     fieldLabel: 'Issue No',
     width: 120,
     valueField:'IssNo',
     vtype: 'hyphen'
 });

Ext.apply(Ext.form.VTypes, {
                hyphenText : "Only numbers and hyphen.",
                hyphenMask:/[0-9-]/,
                hyphenRe: /^\d+-\d{1,2}$/,  //This is the check
                hyphen:function(x){return this.hyphenRe.test(x);}   //Am i missing a numericHyMask: here ??
            });     

      Is hyphenRe: /^\d+-\d{1,2}$/, is correct or
      is hyphenRe: /^\d+-[\d{1,2}]$/, is correct as I want 1 or 2 digits after '-'

Please help me change my VTypes to work properly and do that regex check.

解决方案

Works fine for me. Is the validation itself not working (the field doesn't get underlined when you type invalid stuff in it) or are you missing the error-tooltip? On the latter case add somewhere in your code:

Ext.QuickTips.init();

Otherwise the tooltips wont appear.

这篇关于在Ext Js VType中使用正则表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆