I am trying to get the preg_match '/[^0-9]/' thing below to validate or clear number only entries into a phone field. Am I on the right track as currently I cannot get it to work?
PHP Code:public function validatePhone($phoneVal, $phoneName) {
if (strlen($phoneVal) <= 0) {
$this->setError($phoneName, "Phone Number Required");
} else if (!preg_match('/[^0-9]/', '',$phoneVal)) {
$this->setError($phoneName, "Valid Phone Number Required");
}
}
PHP Code:<p><label>Phone: <span class="required">Required</span>
<input type="text" name="phone" class="textfield" value="<?php echo htmlentities($phone); ?>" />
</label><span class="errors"><?php echo $phoneErr ?></span></p>
Thanks in advance for your oversight.


Reply With Quote

Bookmarks