Appnitro Software Forums » MachForm 2

Check field values are the same


  1. dennis
    Member

    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 3 years ago #
  2. 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 3 years ago #
  3. dennis
    Member

    Yep - that worked... Thanks...

    Posted 3 years ago #
  4. sjones
    Member

    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 2 years ago #
  5. sjones
    Member

    Bump

    Posted 2 years ago #
  6. 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 2 years ago #
  7. eshoop
    Member

    works great!

    Posted 2 years ago #

RSS feed for this topic

Reply