Regular Expression Question
Posted: Tue Sep 17, 2002 11:33 am
I'm validating an address field and I have a regular expression question. Basically I want them to be able to enter "555 maple ave"
and I have this regexp but I was wondering if there was an easier way of doing it.
basically I want them to enter anything they want as long as its alpha numeric and/or has a period
so...
Maple Ave. IS OK
766 Oak St IS OK
894 slkj////sdlkj'; IS NOT OK
and I have this regexp but I was wondering if there was an easier way of doing it.
Code: Select all
<?php
// Check the address 1 field.
if (eregi ("^їa-z0-9]*її]]*їa-z0-9]*її]]*їa-z0-9]*$", $_POSTї'f_add1'])) {
$e = TRUE;
} else {
$e = FALSE;
$messageї] = "Please enter an address1 that consists only of letters and numbers.";
}
?>so...
Maple Ave. IS OK
766 Oak St IS OK
894 slkj////sdlkj'; IS NOT OK