ExtJs NumberField

I am using ExtJs NumberField. It’s good that he checks that only numbers are entered. But I also want a hyphen. How can I go to javascript editing

  var <portlet:namespace/>issueNoField = new Ext.form.NumberField({  //This takes only numbers
             fieldLabel: 'Issue No',
             width: 120,
             displayField: 'Enter no',  
             valueField:'IssNo'
         });
+5
source share
7 answers
var <portlet:namespace/>issueNoField = new Ext.form.TextField({  //This takes only numbers
  fieldLabel: 'Issue No',
  width: 120,
  regex: /[1-9-]*/
});
+8
source

Use the "baseChars" option.

     var <portlet:namespace/>issueNoField = new Ext.form.NumberField({  //This takes only numbers
         fieldLabel: 'Issue No',
         width: 120,
         displayField: 'Enter no',  
         valueField:'IssNo'
         baseChars: "0123456789-"
     });
+2
source

Fiddle

maskRe

maskRe: /^[0-9 -]$/

+1

, (99999-9999)? , .

, "12-345" "123-45" , , . .

0

Regex , :

maskRe: /[1-9-]/,
0
{
xtype: 'textfield',
mask: '(999) 999-9999'
}

, , text field , .

.

:

'9999999999'
'999-999-9999'

0

All Articles