Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Extjs Form Validtion

I am using Extjs Ext.form.FormPanel to create a form that will contain some fields like name, company,...,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.com/projects/masked-input-plugin/

like image 386
Ahmad Avatar asked Jun 09 '26 12:06

Ahmad


1 Answers

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
like image 187
instanceof me Avatar answered Jun 11 '26 23:06

instanceof me



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!