admin管理员组

文章数量:1404927

I am using Extjs Ext.form.FormPanel to create a form that will contain some fields like name, pany,...,etc. Among the fields will be zip code and phone number, let's take the zip code problem, the zip code could be 5 numbers or 5 numbers plus 4 characters, I don't want to create two separate fields for the zip code, is there a way that I could create one field and prevent users from entering the zip code wrongly, just as the following jQuery plugin does:

/

I am using Extjs Ext.form.FormPanel to create a form that will contain some fields like name, pany,...,etc. Among the fields will be zip code and phone number, let's take the zip code problem, the zip code could be 5 numbers or 5 numbers plus 4 characters, I don't want to create two separate fields for the zip code, is there a way that I could create one field and prevent users from entering the zip code wrongly, just as the following jQuery plugin does:

http://digitalbush./projects/masked-input-plugin/

Share asked Jun 18, 2009 at 20:15 AhmadAhmad 2251 gold badge3 silver badges9 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 4

ExtJS has vtypes, that let you write validation code.

Simpler: TextFields have a regex configuration option that forces match on validation. Your regex can be (assuming space separator then a-z only, case-insensitive):

/^\d{5}(? [a-z]{4})?$/i

If your intent is to accept ZIP or ZIP+4, the regex format should be as follows:

/^\d{5}(?-\d{4})?$

The optional delimiter should be a dash, and the four "characters" should always be numbers.

本文标签: javascriptExtjs Form ValidtionStack Overflow