ASP.NET - AutoCompleteType TextBox Numeric Validation

Asked By Jem Savery on 16-Jul-11 02:08 AM
Hi Friends,

I have a Textbox declared in UserControl, and I am using it on my page as following

<mcitControl:SimpleTextBox ID="txtPhoneNumber" runat="server" AutoCompleteType="Cellular"
                    CssClass="adminInput" Width="180" />&nbsp;

But now I want to change the format of the textbox. Also when I add RegularExpressionValidator below this, it gives following error.

Control 'txtPhoneNumber' referenced by the ControlToValidate property of 'revPhone' cannot be validated.

Currently the format for the PhoneNumber field is wrong, I need to validate it to UK Phone number format. Can I change the AutoCompleteType validation format, if yes from where I can change it?

Please help.
Devil Scorpio replied to Jem Savery on 16-Jul-11 02:17 AM
Hi Jem,

This error occurs because the custom control doesn't have the same signature as a regular text box (because it also contains a label). I think if you start off your custom control as inheriting from text box so that all the text box hooks
exist (.NET will think it's just like any other text box) then your control will work.
Jem Savery replied to Devil Scorpio on 16-Jul-11 02:21 AM
Can we change the format (or regular expression) of AutoComplete="Cellular"

and how it compares values with localization.?

Thanks.
Devil Scorpio replied to Jem Savery on 16-Jul-11 02:48 AM
Hi jem,

Cellular is one of the possible value of autocomplete category. so your code sets the AutoCompleteType mode to "Cellular"
Jem Savery replied to Devil Scorpio on 16-Jul-11 02:54 AM
The value is already set to AutoCompleteType="cellular" but I want to apply a RegularExpressionValidator for UK Phone format to the control.
Devil Scorpio replied to Jem Savery on 16-Jul-11 04:00 PM
Hi Jem,

Assuming (07|447|\+447) are the codes for the UK, then this regex should be used

^((07|447|\+447)\d{9})$

Mobile - 07856920000
Phone - 447700912345,+447700912345