Milliment Posted January 9, 2010 Share Posted January 9, 2010 Hi guys i wonder if anyone can help me with this, In italy we need to take a Codice Fiscale (National insurance number or Social Security) for any orders. Now before i desided to use WHMCS i was developing my own system but gave up as i dident have the time to do it. Anyway i wrote a function that would check if the Codice Fiscale was the correct make. Now here is my origional script function valid_cf($str) { return ( ! preg_match ( "/^[a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9]{3}[a-zA-Z]$/", $str ) ) ? FALSE : TRUE; } Can anyone help convert it into a working action hook please. Thanks Anthony 0 Quote Link to comment Share on other sites More sharing options...
rmccny Posted January 9, 2010 Share Posted January 9, 2010 I don't think an actionhook is necessary for what you're trying to accomplish. In fact, it may be overkill. My suggestion would be to create a custom client field and use your regex string for validation, which can be pasted right into the validation box when creating the field. 0 Quote Link to comment Share on other sites More sharing options...
Milliment Posted January 9, 2010 Author Share Posted January 9, 2010 Ahhhhh ok, so the validation field can accept php, i did not no that. 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted January 9, 2010 Share Posted January 9, 2010 Ahhhhh ok, so the validation field can accept php, i did not no that. It doesn't accept PHP, but accepts a regular expression check which you also use in your PHP-code. See also: http://wiki.whmcs.com/Custom_Fields#Regular_Expression_Validation 0 Quote Link to comment Share on other sites More sharing options...
rmccny Posted January 9, 2010 Share Posted January 9, 2010 It doesn't accept PHP, but accepts a regular expression check which you also use in your PHP-code. See also: http://wiki.whmcs.com/Custom_Fields#Regular_Expression_Validation Exactly, so if your expression doesn't return a match the field doesn't pass validation. Pretty slick actually. 0 Quote Link to comment Share on other sites More sharing options...
Milliment Posted January 9, 2010 Author Share Posted January 9, 2010 That workes perfectly thanks guys realy apriciate it. 0 Quote Link to comment Share on other sites More sharing options...
rodiguim Posted February 26, 2010 Share Posted February 26, 2010 That workes perfectly thanks guys realy apriciate it. Sorry could you share the code? 0 Quote Link to comment Share on other sites More sharing options...
m00 Posted February 26, 2010 Share Posted February 26, 2010 It's just the expression from the PHP-code from the first post: /^[a-zA-Z]{6}[0-9]{2}[a-zA-Z][0-9]{2}[a-zA-Z][0-9]{3}[a-zA-Z]$/ 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.