Answered by:
Numbers only in mobile web form

Question
-
User-1696758683 posted
Hi all.....
How can i allow only numbers ('0123456789') and dot('.') to be input into my textbox in my mobile web form ....
i am using vb.net 2005......and i am fresh to mobile ....
Thanks
Wednesday, October 31, 2007 12:41 AM
Answers
-
User743172522 posted
Try this regular expression with your textbox control...
<
asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="**" ValidationExpression="^[0-9,.]+$"></asp:RegularExpressionValidator>- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, October 31, 2007 1:51 AM -
User113421904 posted
Hi goh6613,
Yes. You can use the code snippet provided in the last post. I've changed it to mobile:Textbox control.
<%@ Page Language="C#" AutoEventWireup="true" %><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p><o:p> </o:p><%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %><o:p></o:p><html xmlns="http://www.w3.org/1999/xhtml"><o:p></o:p><body><o:p></o:p> <mobile:Form ID="Form1" Runat="server"><o:p></o:p> <mobile:TextBox ID="TextBox1" Runat="server"><o:p></o:p> </mobile:TextBox><o:p></o:p> <mobile:RegularExpressionValidator ID="RegularExpressionValidator1" Runat="server"<o:p></o:p> ControlToValidate="TextBox1" ErrorMessage="Wrong Format" ValidationExpression="^[0-9,.]+$"><o:p></o:p> </mobile:RegularExpressionValidator><o:p></o:p> </mobile:Form><o:p></o:p></body><o:p></o:p></html>
One issue is that you may need to modify the regular expression since this expression validates the inputs with multiple dots, e.g. the following are validate
123456
123.456
12.34.56
If you want to have one or less dot in the input, you could try this: ^\d*\.{0,1}\d+$
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, November 5, 2007 4:12 AM
All replies
-
User743172522 posted
Try this regular expression with your textbox control...
<
asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="TextBox1" ErrorMessage="**" ValidationExpression="^[0-9,.]+$"></asp:RegularExpressionValidator>- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, October 31, 2007 1:51 AM -
User-1696758683 posted
hi dreamz,
what i want is input number and dot in to mobile web form textbox, this way can work ?
and for the mobile phone's keypad......how it can recognise the number and alphabet ??
thanks
Wednesday, October 31, 2007 8:42 PM -
User113421904 posted
Hi goh6613,
Yes. You can use the code snippet provided in the last post. I've changed it to mobile:Textbox control.
<%@ Page Language="C#" AutoEventWireup="true" %><?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p><o:p> </o:p><%@ Register TagPrefix="mobile" Namespace="System.Web.UI.MobileControls" Assembly="System.Web.Mobile" %><o:p></o:p><html xmlns="http://www.w3.org/1999/xhtml"><o:p></o:p><body><o:p></o:p> <mobile:Form ID="Form1" Runat="server"><o:p></o:p> <mobile:TextBox ID="TextBox1" Runat="server"><o:p></o:p> </mobile:TextBox><o:p></o:p> <mobile:RegularExpressionValidator ID="RegularExpressionValidator1" Runat="server"<o:p></o:p> ControlToValidate="TextBox1" ErrorMessage="Wrong Format" ValidationExpression="^[0-9,.]+$"><o:p></o:p> </mobile:RegularExpressionValidator><o:p></o:p> </mobile:Form><o:p></o:p></body><o:p></o:p></html>
One issue is that you may need to modify the regular expression since this expression validates the inputs with multiple dots, e.g. the following are validate
123456
123.456
12.34.56
If you want to have one or less dot in the input, you could try this: ^\d*\.{0,1}\d+$
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, November 5, 2007 4:12 AM -
User-1696758683 posted
thanks Zhao Ji Ma ...
i will have a try after this......
Tuesday, November 6, 2007 5:42 AM