Text Fields With Limited Chracters

Welcome. Please Login, Register, Or Activate! 
type your username and password to login
Date: November 24, 2009, 11:17 PM
432118 members and 299087 Topics
Latest Member: emusemove
Nairaland [Nigerian Forum] Home Help Search Who is currently online? Login Register
Nairaland Forum  |  Technology  |  Webmasters (Moderators: OmniPotens, yawa-ti-de)  |  Text Fields With Limited Chracters
Pages: (1) Go Down Send this topic Notify of replies
Author Topic: Text Fields With Limited Chracters  (Read 72 views)
Dr. Ayo
Text Fields With Limited Chracters
« on: October 13, 2009, 10:02 PM »

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.
wizzykid
Re: Text Fields With Limited Chracters
« #1 on: October 13, 2009, 10:40 PM »

which package do u use? dreamweaver?
OmniPotens (m)
Re: Text Fields With Limited Chracters
« #2 on: October 14, 2009, 12:18 AM »

@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.
OmniPotens (m)
Re: Text Fields With Limited Chracters
« #3 on: October 14, 2009, 12:36 AM »

Try using this Javascript regular expressions to see if it will work

Code:
[b]<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>[/b]
lightwalk (m)
Re: Text Fields With Limited Chracters
« #4 on: October 14, 2009, 01:01 AM »

That's very easy to do in ASP.NET You can check out codeproject.com
xanadu
Re: Text Fields With Limited Chracters
« #5 on: October 14, 2009, 07:30 AM »

@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.
Dr. Ayo
Re: Text Fields With Limited Chracters
« #6 on: October 15, 2009, 10:57 AM »

Thanks everyone for your reply.

@Xanadu: I followed your reference to dynamicdrive and it helped
Thanks Omnipotence for the script.
 Need Assistance  I Want To Edit And Upload A Website  Please Check Out And Critique My Facebook App  Page 2
Pages: (1) Go Up Send Topic to Friend by E-mail Reply 


Sections: Autos/Cars (2) Jobs/Vacancies (2) (3) Career Talk Education General(2) Politics Romance Computers Phones Travel
Sports Fashion Health Religion Celebrities TV/Movies (2) Music/Radio (2) Books Webmasters Programming

Links: Page1 Page2 Page3 Page4 Page5 Page6 Page7 Page8 Page9 Page10

Nairaland is owned by Oluwaseun Osewa. See also: Nairalist Classified Ads
Nairaland Forum | Powered by SMF 1.0.12.
© 2001-2005, Lewis Media. All Rights Reserved.