Mar 13th, 2015, 11:13 AM
Hello,
A newbie question:
I am trying to find a way to check the content of various textbox fiels on my form so as to ensure that they contain a number. If the number has decimal digits, those should be separated by a dot (not by a comma that often people use).
For that, I am trying to use the Custom Fields module. I have created a new field type ("test"), based on the Textbox field type. I would like to add a validation rule that would use a regular expression for the validation of the textbox, which in my case would be "/^\d*\.{0,1}\d*\z/".
I assume that, for an external form I would use something like
rules.push("reg_exp,field_name,'/^\d*\.{0,1}\d*\z/',Error message");
However, how could I do that using the interface of the Custom Fields module? The form that I plan to use this validation on is an internal one.
Thanks in advance for your help!
G.
PS
In the mean time, I have managed to go around the problem. I have used a Hooks rule for "ft_create_blank_submission, end" and an identical one for "ft_update_sumbission, end", which goes through the $_POST fields that should have numbers, checks that the strings have number values, changes the commas to dots and then updates the content of the fieds prior to submission.
However, changing the user input in that way, is something that I would like to avoid.
A newbie question:
I am trying to find a way to check the content of various textbox fiels on my form so as to ensure that they contain a number. If the number has decimal digits, those should be separated by a dot (not by a comma that often people use).
For that, I am trying to use the Custom Fields module. I have created a new field type ("test"), based on the Textbox field type. I would like to add a validation rule that would use a regular expression for the validation of the textbox, which in my case would be "/^\d*\.{0,1}\d*\z/".
I assume that, for an external form I would use something like
rules.push("reg_exp,field_name,'/^\d*\.{0,1}\d*\z/',Error message");
However, how could I do that using the interface of the Custom Fields module? The form that I plan to use this validation on is an internal one.
Thanks in advance for your help!
G.
PS
In the mean time, I have managed to go around the problem. I have used a Hooks rule for "ft_create_blank_submission, end" and an identical one for "ft_update_sumbission, end", which goes through the $_POST fields that should have numbers, checks that the strings have number values, changes the commas to dots and then updates the content of the fieds prior to submission.
However, changing the user input in that way, is something that I would like to avoid.