By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,607 Members | 1,138 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,607 IT Pros & Developers. It's quick & easy.

only some character inner text

P: n/a
den
inner a text element if I want to allow the insertion of only:
alphabet's letters a,b,c,.... and A,B,C,...
number and this - and this _

and not want space blank and others characters
what is the better solution ?

the text is used for to assign name at new folders and new files,
so I want to reduce possible risks of dirty code by this text box;
is a good solution to limit the characters (no special characters) ?

---
and for the max lenght for name what solution is preferable to use?
---
for the letters, if the server use linux, is better to use only the
lowercase ?
Feb 9 '07 #1
Share this Question
Share on Google+
3 Replies

P: n/a
den wrote:
inner a text element if I want to allow the insertion of only:
alphabet's letters a,b,c,.... and A,B,C,...
number and this - and this _

and not want space blank and others characters
what is the better solution ?
This is best accomplished using server-side code (PHP?) and regular
expressions.
Mick
>
the text is used for to assign name at new folders and new files,
so I want to reduce possible risks of dirty code by this text box;
is a good solution to limit the characters (no special characters) ?

---
and for the max lenght for name what solution is preferable to use?
---
for the letters, if the server use linux, is better to use only the
lowercase ?
Feb 9 '07 #2

P: n/a
On Feb 9, 12:26 pm, Michael White <m...@mickweb.comwrote:
den wrote:
inner a text element if I want to allow the insertion of only:
alphabet's letters a,b,c,.... and A,B,C,...
number and this - and this _
and not want space blank and others characters
what is the better solution ?

This is best accomplished using server-side code (PHP?) and regular
expressions.
Mick


the text is used for to assign name at new folders and new files,
so I want to reduce possible risks of dirty code by this text box;
is a good solution to limit the characters (no special characters) ?
---
and for the max lenght for name what solution is preferable to use?
---
for the letters, if the server use linux, is better to use only the
lowercase ?- Hide quoted text -

- Show quoted text -
I would disagree with the server-side comment. Unless I miss
understand the question all together. You have a text box that a user
inputs a name to assign a folder. And you want to limit what charcters
they can input into that can be sent to the server-side script. The
reason I don't agree with the server-side script comment is because
you would have to reload the page to find out if the user screwed
something up...that would take to long and especially when javascript
can do it.

You can do it one of two ways. By not allowing anything but those
characters to be typed in to the textbox (using the on keypress
function of the text box) or by scanning the string that they input
into the text onBlur or onSubmit (which ever you prefer). This way
your page determines if the fields are ready to submit before sending
it back to the server.

If I miss understood your question I am sorry otherwise if you need
more help let me know.

Adambrz
www.adambrz.com

Feb 9 '07 #3

P: n/a
Adambrz said the following on 2/9/2007 2:32 PM:
On Feb 9, 12:26 pm, Michael White <m...@mickweb.comwrote:
>den wrote:
>>inner a text element if I want to allow the insertion of only:
alphabet's letters a,b,c,.... and A,B,C,...
number and this - and this _
and not want space blank and others characters
what is the better solution ?
This is best accomplished using server-side code (PHP?) and regular
expressions.
Mick


>>the text is used for to assign name at new folders and new files,
so I want to reduce possible risks of dirty code by this text box;
is a good solution to limit the characters (no special characters) ?
---
and for the max lenght for name what solution is preferable to use?
---
for the letters, if the server use linux, is better to use only the
lowercase ?- Hide quoted text -
- Show quoted text -

I would disagree with the server-side comment.
You are entitled to disagree but you would be on the wrong side of the
argument.
Unless I miss understand the question all together. You have a text box
that a user inputs a name to assign a folder. And you want to limit what
characters they can input into that can be sent to the server-side script.
The reason I don't agree with the server-side script comment is because
you would have to reload the page to find out if the user screwed
something up...that would take to long and especially when javascript
can do it.
Javascript - on the client - can attempt to validate the input. But it
can also be easily bypassed.

inputRef.value="anything I want";
formRef.submit();

And I bypass any and all JS validation. If you want validation -
reliable validation - you *must* do it on the server where you know it
can't be bypassed.
You can do it one of two ways. By not allowing anything but those
characters to be typed in to the textbox (using the on keypress
function of the text box) or by scanning the string that they input
into the text onBlur or onSubmit (which ever you prefer). This way
your page determines if the fields are ready to submit before sending
it back to the server.
The server must still validate the input though.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 9 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.