brandonwarsaw
New Member
I would like to create a validate function for numbers only, actually I have those ones that works fine, and I tried to create one myself, but it's unfortunately not working. Here are the alphanumeric and others working fine :\[code\]// Validatorsprivate function custom($validator, $value){ return call_user_func($validator, $value, $this->request, $this->id);}private function alphanumeric($value, $custom){ return preg_match('/^(['.$custom.'a-z0-9_]*)$/i', $value);}private function valid_email($value){ return preg_match('/^\S+@\S+\.\S+$/', $value);}\[/code\]And the one I tried to create by modifying the alphanumeric one : \[code\]private function numbers_only($value, $custom){ return preg_match('/^(['.$custom.'0-9_]*)$/i', $value);}\[/code\]What's wrong with this one ?EDIT :I also have a JS helping with the form, for alphanumeric it's : \[code\]Form.prototype.alphanumeric = function(value, custom){ return !value.replace(new RegExp('['+custom+'a-z0-9_]', 'ig'), '').length;};\[/code\]What would be the JS for numeric only ?