Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-22-2013, 06:24 AM   PM User | #1
saravanataee
New to the CF scene

 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
saravanataee is an unknown quantity at this point
Validate Textarea to accept only characters no special symbols or numbers.

Dear all,
Greetings,
I have been scratching my mind for couple of times to know how could i restrict a textarea to only accept character's A-Z. No special symbols like @#!| and numbers are allowed. When i give them it should be throw me an error message.

I tried few jquery implementations. But nothing works for me as i m not aware how to apply them.

Can some one help on how to acheive this.

Would be great.!

Thanks!
saravanataee is offline   Reply With Quote
Old 02-22-2013, 08:09 AM   PM User | #2
felgall
Master Coder

 
felgall's Avatar
 
Join Date: Sep 2005
Location: Sydney, Australia
Posts: 5,460
Thanks: 0
Thanked 499 Times in 491 Posts
felgall is a jewel in the roughfelgall is a jewel in the roughfelgall is a jewel in the rough
<textarea pattern="^[a-zA-Z]*$"> should do it in browsers that support HTML 5. To add support for that to other browsers see http://javascriptexample.net/domform12.php
__________________
Stephen
Learn Modern JavaScript - http://javascriptexample.net/
Helping others to solve their computer problem at http://www.felgall.com/
felgall is online now   Reply With Quote
Old 02-22-2013, 01:57 PM   PM User | #3
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,653
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
HTML5 sure is neat.
But you still cannot trust it. That assumes that an HTML form is used and obeys the pattern. Its pretty much the same with a preg_match though.
PHP Code:
$p '/^[a-z]*$/i';
if (
preg_match($p$content))
{
    print 
'thats good.';

Where $content is the string.
You can also use ctype_alpha which is also just a-z case insensitive.
__________________
As of PHP 5.5, the MySQL library has been officially deprecated. It is recommended to move to either MySQLi or PDO libraries for your mysql connectivity. See here for help choosing which interface you prefer: http://php.net/manual/en/mysqlinfo.api.choosing.php
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Tags
jquery, php, texarea, validation

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 11:57 PM.


Advertisement
Log in to turn off these ads.