0

I'd like to have special fields with ASP.NET, I use ASP:TextBox for my login page. The idea is : when you are in a mobile device, it recognizes the field and purpose a special keyboard with only numbers (my login page uses only numbers)

I tested that, but it doesn't works :

 <asp:TextBox CssClass="LoginTxtBox" ID="Txt_nom" runat="server" AutoCompleteType="Disabled" ForeColor="Black" MaxLength="20" Width="100%" Height="30px" TextMode="Number"></asp:TextBox>

"Number isn't a member of System.UI.WebControls.TextBoxMode"

I checked and Number is a member of this. I don't understand why I can't debug with that. (I can launch the website with IIS, no issue)

Thanks for your help !

Barett
  • 5,826
  • 6
  • 51
  • 55
Alex
  • 33
  • 12

2 Answers2

1

this will help:

<asp:TextBox ID="Txt_nom" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" ControlToValidate="Txt_nom" runat="server" ErrorMessage="Only Numbers allowed" ValidationExpression="\d+"></asp:RegularExpressionValidator>
Eliad
  • 140
  • 1
  • 11
  • I think it will only check if you entered numbers or letters, right ? I need to ban letter, to use a Numbers keyboard on my smart-phone, you know what I mean ? – Alex May 18 '15 at 10:11
1

could you try:

<asp:TextBox CssClass="LoginTxtBox" ID="Txt_nom" runat="server" AutoCompleteType="Disabled" ForeColor="Black" MaxLength="20" Width="100%" Height="30px" type="Number"></asp:TextBox>

changed "TextMode" into "type".

see more info here: http://mobiforge.com/design-development/html5-mobile-web-forms-and-input-types

  • I tried Type=" ", it works for my first field (Username) but it doesn't the second because I need a password field with only numbers. Any idea ? – Alex May 18 '15 at 10:09
  • ahh the second field is a passwordfield. And you want to show the numberpad only for the password field. see here, someone else had the same question once :) http://stackoverflow.com/questions/19126856/make-input-type-password-use-number-pad-on-mobile-devices – Ronald van Meer May 18 '15 at 10:14
  • Thanks i'll see that ! – Alex May 18 '15 at 11:24
  • I just tried but it doesn't work, it's fine for Login field, the main problem is for password. – Alex May 18 '15 at 11:36
  • I found a way using your link, because my web app is full responsive (Users can have PC or Smartphone...) So I change Type attribute with javascript if my screen size is for desktop and my fields are like text fields and classic password field. And on my smartphone, I have my keyboard as I want, thanks a lot for your help ! – Alex May 18 '15 at 11:55