I want to add Regexp or similar functionality just like in jquery or PHP to enter only HTTP or number only in textfield of Sencha mean to show error if user doesn't satisfy condition of any Regexp function.How can I implement it?
I want to add Regexp or similar functionality just like in jquery or PHP to enter only HTTP or number only in textfield of Sencha mean to show error if user doesn't satisfy condition of any Regexp function.How can I implement it?
You can listen to the keydown event and check against regexp. If it fails stopEvent() on the event object.
This is a pattern text field that takes a pattern attribute value (HTML5 pattern attrib)
That only allows numbers and keys like delete. In the onKeyDown you can use a RegExp test and if it fails then do the e.stopEvent().Code:Ext.define('Ux.field.PatternText', { extend : 'Ext.field.Text', xtype : 'patterntextfield', config : { pattern : '[0-9]*' }, updatePattern : function(pattern) { var component = this.getComponent(); component.updateFieldAttribute('pattern', pattern); }, initialize : function() { this.callParent(); var component = this.getComponent(); component.input.on({ scope : this, keydown : 'onKeyDown' }); }, onKeyDown : function(e) { var code = e.browserEvent.keyCode; if (!(code >= 48 && code <= 57) && !(code >= 97 && code <= 105) && code !== 46 && code !== 8) { e.stopEvent(); } } });
Mitchell Simoens @LikelyMitch
Modus Create, Senior Frontend Engineer
________________
Need any sort of Ext JS help? Modus Create is here to help!
Check out my GitHub:
https://github.com/mitchellsimoens
Thanks for Help.Where to add as I have code like this
And I also want to add max and min value ie 3 and 1 as number field didn't support.Same for adding only links Regexp function or matcher something.Code:Ext.define("PlayListApp.view.PlayEditor", { extend: "Ext.form.Panel", requires: "Ext.form.FieldSet", alias: "widget.playeditorview", config:{ scrollable: 'vertical', items: [ { xtype: 'textfield', name: 'duration', label: 'Duration', placeHolder:'99', required:true }