PDA

View Full Version : Question about Ext.form.field.TextArea and its stripReturns



sneakyfildy
24 Jul 2012, 12:06 AM
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.TextArea

stripReturns: function(value){ if (value) { value = value.replace(this.returnRe, ''); } return value; } (http://docs.sencha.com/ext-js/4-1/#!/api/Ext.form.field.TextArea)When value in textarea is number exception is thrown and all fails.
Wheres the hidden reason for doing .replace on any value type? Why there's no safety blocks? Textarea is only for text input?

friend
24 Jul 2012, 9:30 AM
From looking at the source of Ext.form.field.TextArea (http://docs.sencha.com/ext-js/4-1/source/TextArea2.html#Ext-form-field-TextArea), it appears that stripReturns is intended to remove any carriage returns in the entered text, where the regex expression /\r/ is used to indicate a carriage return.

I coded a TextArea component and typed in numbers only, then a few carriage returns and it seems to be working correctly for me (ExtJs v4.1.1).

When do you encounter an error in your TextArea field? On blur? And are you doing any custom validation on this field?