This forum is no longer open and is for reading/searching only.
Please use our new MachForm Community Forum instead.
MachForm Community Forums » MachForm 2
Check field values are the same
Started 16 years ago by dennis | 13 posts |
-
I would like to have the email address entered twice and then a quick check to ensure that the values are the same.
Is there a (hopefully easy) way to do this please ?
Thanks..
Posted 16 years ago # -
If you don't mind some modification, yes it is possible.
Let say your form is having id = 3 and your email fields are having id element_1 and element_2 (check the HTML source of your form to see it.
Edit your includes/post-functions.php, around line 46 - 47 you'll find this code:
$element_child_lookup['address'] = 5; $element_child_lookup['simple_name'] = 1;
Right above that code, insert this code:
if($form_id == 3){ if($input['element_1'] != $input['element_2']){ $process_result['status'] = false; $process_result['custom_error'] = 'You must enter the same email address!'; } }
That would do it.
If you are having difficulty, let me know the URL of your form or just send it to customer.service [at] appnitro.com
MachForm Founder
Posted 16 years ago # -
Yep - that worked... Thanks...
Posted 16 years ago # -
The above solution DOES work great.
I have a website that has about 10 email addresses on it. We are being spammed by bots that are finding the addresses on our site. I have decided to create a form for each recipient. All the forms are identically layed out. Will I have to put this code in 10 times?
f($form_id == 13){
if($input['element_2'] != $input['element_3']){
$process_result['status'] = false;
$process_result['custom_error'] = 'You must enter the same email address!';
}
}and change the form id each time, or is there a way to say >=13 and <=23 on the form_id line?
Posted 15 years ago # -
Bump
Posted 15 years ago # -
Are all your forms having the identical email fields element id?
(if you copied your form using the 'duplicate' button, usually they are identical)If they do, you can use something like this:
if($form_id >= 3 && $form_id <= 23){ if($input['element_1'] != $input['element_2']){ $process_result['status'] = false; $process_result['custom_error'] = 'You must enter the same email address!'; } }
otherwise, you'll need to put separate 'if' block for each form.
MachForm Founder
Posted 15 years ago # -
works great!
Posted 15 years ago # -
It does work great but with current versions the code is at about line 70.
QUESTION:
How can I highlight the fields to look like the others that fail to meet criteria??thanks!
Posted 12 years ago # -
@MXZRXP: Take a look at this, it may be of help:
http://www.appnitro.com/forums/topic/confirming-your-email-logic?replies=6#post-19415
Posted 11 years ago # -
The above post by Yuniar worked for me, but like MXZRXP said with the new version the code needs to placed around line 70-ish right above
$element_child_lookup['address'] = 5;
Also I had to change the operator from && to or otherwise the emails would have to match across multiple forms, which is essentially impossible, below is my working code:
// Verification that the email addresses match if($form_id >= 25863 or $form_id >= 25631) { if($input['element_3'] != $input['element_10']) { $process_result['status'] = false; $process_result['custom_error'] = 'Please enter the same email address'; } }
Posted 10 years ago # -
I am running V2.4 and am running into problems and getting the error message "You must enter the same email address!" even when the email addresses are identical. I have used the suggested method Yuniar has suggested above and have changed the Form numbers and Element numbers to match those for my form and I still get the error message. Any suggestion? Thanks.
Posted 10 years ago # -
Have just noticed that the form ID# listed in the embedded code is not the same as the form number that has been assigned by Machform. For example, in the embedded code my Contact Me form is listed as ID=1 whereas when I open the form I discover that the form has ID=145. Strange. On a hunt...
Posted 10 years ago # -
Well, easiest way to fix this problem is just to change the ID number in the .../machform/includes/post-functions.php file to match the ID number that was assigned to it by Joomla. Seems the form takes on the Joomla ID number and not the number that is in the "Embedded Code" section in MachForm. Strange again...
Posted 10 years ago #
Reply
You must log in to post.