|
Dr. Ayo
|
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
|
which package do u use? dreamweaver?
|
|
|
|
|
|
OmniPotens (m)
|
@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)
|
Try using this Javascript regular expressions to see if it will work [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)
|
That's very easy to do in ASP.NET You can check out codeproject.com
|
|
|
|
|
|
xanadu
|
@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.htmHope that helps.
|
|
|
|
|
|
Dr. Ayo
|
Thanks everyone for your reply.
@Xanadu: I followed your reference to dynamicdrive and it helped Thanks Omnipotence for the script.
|
|
|
|
|
|