View Full Version : simple modification to open.inc.php
wcwoodson
01-10-2008, 05:27 PM
I'd like to allow non phone number formats in the telephone field.
I'm pretty new to all of this, but I'm enjoying the learning curve.
Thanks
wcwoodson
01-10-2008, 09:04 PM
So the necessary code appears to be in one or both of these: class.validator.php or class.format.php
What I would really like is the field to allow any information to be entered.
Any ideas?
So the necessary code appears to be in one or both of these: class.validator.php or class.format.php
What I would really like is the field to allow any information to be entered.
Any ideas?
We are looking at the possibility to custom specify the fields. So this will become available soon. But I looked at it very quickly and it seems that if you want to do what you want you have to change the following.
In class.validator.php change
function is_phone($phone) {
$stripped=eregi_replace("(\(|\)|\-|\+)","",ereg_replace("([ ]+)","",$phone));
return (!is_numeric($stripped) || ((strlen($stripped)<7) || (strlen($stripped)>13)))?false:true;
}
into
function is_phone($phone) {
return true;
}
I did not test this code, so I'm not sure if it will work like you want or that it will give any problems.
wcwoodson
01-10-2008, 09:59 PM
I'm sure this will irk those who know what they are doing, but since I don't know...much, all I did was make the code approve the input even if it failed the validation.
This is from the class.validator.php and all I did was change false:true to true:true.
function is_phone($phone) {
$stripped=eregi_replace("(\(|\)|\-|\+)","",ereg_replace("([ ]+)","",$phone));
return (!is_numeric($stripped) || ((strlen($stripped)<7) || (strlen($stripped)>13)))?true:true;
}
If anyone cares to share the proper answer, please post as I expect I'm breaking some unwritten code of cool.
I'm sure this will irk those who know what they are doing, but since I don't know...much, all I did was make the code approve the input even if it failed the validation.
This is from the class.validator.php and all I did was change false:true to true:true.
function is_phone($phone) {
$stripped=eregi_replace("(\(|\)|\-|\+)","",ereg_replace("([ ]+)","",$phone));
return (!is_numeric($stripped) || ((strlen($stripped)<7) || (strlen($stripped)>13)))?true:true;
}
If anyone cares to share the proper answer, please post as I expect I'm breaking some unwritten code of cool.
LOL :D
This is easier and doing exactly the same. Anyway you are asking for a proper answer, but you want the field to be able to contain any information right? What for solution do you have in mind then? Because you solution makes it possible to contain everything at the moment.
wcwoodson
01-10-2008, 10:13 PM
Thanks for the solution. I have been playing around with my solution and it seems to work. So I expect your cleaner solution would work too.
wcwoodson
01-10-2008, 10:18 PM
I'm happy with the solution (both of them). I guess in my mind a proper solution would be to not validate the phone field at all (just like full name field doesn't go through the validator).
vegaslaptop
01-19-2008, 12:38 AM
In a corporate world you want to be able to put just an extension for example and the standard phone field check becomes an annoyance. I will apply the above code but just like wcwoodson I would say that this field should be customizable.
Regards
cceller
11-18-2008, 09:10 PM
Thanks for this helpful snippet of code - - - we also wanted to allow anything in this field since we use extensions :D .