The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Text field not working
tudsy
post May 2 2018, 12:50 PM
Post #1


Advanced Member
****

Group: Members
Posts: 151
Joined: 30-September 14
Member No.: 21,611



Hi

I am trying to ask a user for their Age (3 numbers) but I am getting the text field greater than 3 chars.


<p align="center">3. Please input your Age:</p>


<input type=“text” name=“Age” required=“required” maxlength=‘3’ size=‘3’ pattern=“[0-9]+” />

Any help will be appreciated.

Tudsy
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
pandy
post May 2 2018, 04:18 PM
Post #2


Don't like donuts. Don't do MySpace.
********

Group: WDG Moderators
Posts: 17,967
Joined: 9-August 06
Member No.: 6



Is that copied from the actual HTML document? In that case it's because you use curly quotes and prim signs. Use normal, straight quotes. And don't use Word and the like to write HTML or any other computer language, as wordprocessors may spiff up what you write with things like this. Use a plain text editor. Only ascii characters are allowed in the actual markup or code in case of programming. Same goes for CSS.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post May 3 2018, 12:33 PM
Post #3


.
********

Group: WDG Moderators
Posts: 7,867
Joined: 10-August 06
Member No.: 7



Also the SIZE attribute does not work very well in browsers to control textfield width, use CSS instead.

The PATTERN regex may not work like you want. [0-9] matches the zero character, and the + symbol allows one or more occurence of the character, meaning it allows user values like 0, 00 or 000 (the MAXLENGTH attribute prevents 0000 and longer strings).

See also https://www.regular-expressions.info/numericranges.html
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 17th August 2018 - 06:47 AM