Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,166,186 members, 7,864,093 topics. Date: Tuesday, 18 June 2024 at 11:41 AM

Text Fields With Limited Chracters - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Text Fields With Limited Chracters (635 Views)

Two-way SMS Text Verification/product Activation Using Long Code (Tutorial) / Problem: Centering Text Using Php's Imagettftext / How To Select All The Fields From A Mysql Table And Access The Data Individually (2) (3) (4)

(1) (Reply) (Go Down)

Text Fields With Limited Chracters by DrAyo1(m): 10:02pm On Oct 13, 2009
I was on a page building a form, and I will like to limit the characters that can be entered in the text field.
That is when the user is typing in the browser and the characters reach the limit (I chose) he won't be able to type anything more.
Also, how would I prevent some characters like #. @ etc in the text field.

Thanks.
Re: Text Fields With Limited Chracters by wizzykid(m): 10:40pm On Oct 13, 2009
which package do u use? dreamweaver?
Re: Text Fields With Limited Chracters by OmniPotens(m): 12:18am On Oct 14, 2009
@Dr. Ayo: Have you learnt about "maxlength" in text fields before? If not go learn about maxlength. You use that to special the maximun number of character allowed in a text field.

As for the special characters elimination, why not use PHP to strip those things off. I'll still fix up something in case I can lay my hand at one.
Re: Text Fields With Limited Chracters by OmniPotens(m): 12:36am On Oct 14, 2009
Try using this Javascript regular expressions to see if it will work

<script language="JavaScript"><!--
var temp = new String('This is a te!!!!st st>ring, So What, ');
document.write(temp + '<br>');
temp = temp.replace(/[^a-zA-Z 0-9]+/g,'');
document.write(temp + '<br>');
//--></script>
Re: Text Fields With Limited Chracters by lightwalk(m): 1:01am On Oct 14, 2009
That's very easy to do in ASP.NET You can check out codeproject.com
Re: Text Fields With Limited Chracters by xanadu: 7:30am On Oct 14, 2009
@Dr Ayo,

I am presuming you mean restricting text entered in a textarea? I am not quite sure that the 'maxlength' attribute is supported for textarea fields (it supports the 'columns', 'rows' and 'name' attributes). It is supported in text fields.

For textareas, you can still use the maxlength attribute but with some Javascript help.

Check this web page out for a sample script that should make this clearer:

http://www.dynamicdrive.com/dynamicindex16/maxlength.htm

Hope that helps.
Re: Text Fields With Limited Chracters by DrAyo1(m): 10:57am On Oct 15, 2009
Thanks everyone for your reply.

@Xanadu: I followed your reference to dynamicdrive and it helped
Thanks Omnipotence for the script.

(1) (Reply)

I Need A Gps With Naija Street Map On It / Check Out Free Website Template / Weebly Rocks Check It Out.

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 17
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.