I working on the form where i want to restrict the user to input only characters,digit, . , and white space. i want to validate 2 text field and one text area.
[code=html]if(!preg_match(“/^[a-zA-Z0-9].*$/”,$field1))
{
$turnmsg = “<b><font color=’red’> Only letters,spaces & . are allowed </font></b>”;
}
if(!preg_match(“/^[a-z A-Z].*$/”,$field2))
{
$turnmsg = “<b><font color=’red’> Only letters,spaces & . are allowed </font></b>”;
}
if(!preg_match(“/^[a-z A-Z].*$/”,$textarea1))
{
$turnmsg = “<b><font color=’red’> Only letters,spaces & . are allowed </font></b>”;
}
The problem is that when i applied preg_match on single field with if condition its working fine , but with the mutiple if condition its fail. any alternatives or do i needs any modificaiton into my code.
Thanks ,
Ashish