[PHP-DB] Re: Regular Expression

2004-04-19 Thread Andy Ladouceur
A regexp like this should work:

/^([a-zA-Z]|\s)+$/

Cheers,
Andy Ladouceur
Andy Amol wrote:

Hi,
   I would like to test whether a given sting contains only character, it should also support spaces.
eg Course Book String. I am able to test CourseBookString.
 
Also I would like to know how can we avoid wild chars like *, or any other char apart from alpha numeric char.
 
Thanks.


-
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Re: [PHP-DB] Re: Regular Expression

2004-04-19 Thread andy amol
hi,
  Thanks for the reply.
I want to know how to include char - i.e a dash . I want to test for it.
eg: COSC-3006.
I should be able to test that string as valid.
Also is there a way in which the form validation fails but when the user goes back to 
the same form its previous values are retained.
 
eg: Suppose the user enters its name, age and phone number.
 But the phone number is wrongly entered. Then he goes back, the old values should 
still be displayed. Only the phone number should be cleared.
 
Also how to program for such a back button.
In what I have done is simply called the previous form, so it clears all the values.
Any help in appreciated.
 
Thanks in advance.
bye.
Kelly Hallman [EMAIL PROTECTED] wrote:
Apr 18 at 11:01pm, Andy Ladouceur wrote:
 Andy Amol wrote:
  I would like to test whether a given sting contains only character, it
  should also support spaces. eg Course Book String. I am able to test
  CourseBookString. Also I would like to know how can we avoid wild
  chars like *, or any other char apart from alpha numeric char.

 A regexp like this should work:
 /^([a-zA-Z]|\s)+$/

/^[A-Za-z\s]+$/ would be a better way of putting it.
however, \s would match tabs (also CR and/or LF in some regex engines).

to only alpha or space, this would work best:
/^[A-Za-z ]+$/

-- 
Kelly Hallman

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


-
Do you Yahoo!?
Yahoo! Photos: High-quality 4x6 digital prints for 25¢

Re: [PHP-DB] Re: Regular Expression

2004-04-19 Thread David Robley
[EMAIL PROTECTED] (Andy Amol) wrote in
news:[EMAIL PROTECTED]: 

 hi,
   Thanks for the reply.
 I want to know how to include char - i.e a dash . I want to test for
 it. eg: COSC-3006.
 I should be able to test that string as valid.
 Also is there a way in which the form validation fails but when the
 user goes back to the same form its previous values are retained. 
  
 eg: Suppose the user enters its name, age and phone number.
  But the phone number is wrongly entered. Then he goes back, the
  old values should still be displayed. Only the phone number
  should be cleared. 
  
 Also how to program for such a back button.
 In what I have done is simply called the previous form, so it clears
 all the values. Any help in appreciated.

Call the previous form but pass it the values as hidden fields. Or better, 
do all the input, validation and etc in the same script, passing the values 
each time.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php