PDA

View Full Version : [FIXED] TextBox Regex property



clrnbeek
Apr 20, 2008, 8:10 AM
Hi,
I'm trying to use regular expression validation with the Textbox, but i notice that



<cool:TextBox Runat="server" AllowBlank="false" Regex="/^[a-zA-Z_]+$/"></cool:TextBox>


is rendered as:



this.m_c_ctl00=new Ext.form.TextField({
allowBlank:false,
applyTo:"m_c_ctl00_TextBox",
regex:"/^[a-zA-Z_]+$/",
id:"m_c_ctl00"
});}


With the double-quotes that are placed around the regex property value, ExtJs throws a Javascript error.
When I manually remove the double quotes, the validation works fine.

Am I declaring regex validation the right way? Or could this be a bug?

Greetings,
Martijn

geoffrey.mcgill
Apr 21, 2008, 3:40 AM
Hi Martijn,

Thanks for pointing out this Regex bug. At some point we changed the way the Json serializer was handling Regex property types and this caused a bug.

I've found the problem code, fixed and tested to ensure it's now working properly. The new code will be included with the next release (v0.5).

Until the 0.5 release, I would recommend removing the regular expression from the "Regex" property and add manually during the <Render> event.

Example


<cool:TextBox ID="TextBox1" Runat="server" AllowBlank="false">
<ClientEvents>
<Render Handler="function(el){el.regex = /^[a-zA-Z_]+$/;}" />
</ClientEvents>
</cool:TextBox>

For reference, the syntax for the above control tag will be changing slightly with the version 0.5 release.

Example


<ext:TextBox ID="TextBox1" Runat="server" AllowBlank="false">
<Listeners>
<Render Handler="function(el){el.regex = /^[a-zA-Z_]+$/;}" />
</Listeners>
</ext:TextBox>

Hope this helps.