This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 3

Confirming Your Email Logic


  1. ConnecTED
    Member

    Hello, I have created this form:

    http://www.displaycalibrations.com/machform/view.php?id=12705

    and I have added 2 fields for the user to fill his email address:

    Your Email + Confirm Your Email Fields.

    How is possible to set the logic or by adding an extra CSS code, to display an error if these 2 user entries are not matching? when the user is submitting his data...

    Posted 10 years ago #
  2. AMurray
    Pro Member

    I would suggest that the "email" field that you drag onto the form in the Edit mode of MF, would need to be added to (by Appnitro as a feature enhancement), to include the "email check" and validation plus allow for a custom error message etc.

    I tried doing this with the current conditional logic settings, but it doesn't allow a way to compare two fields (with unknown values), but only compare one field (at a time) with a given value in the logic settings.

    Posted 10 years ago #
  3. ConnecTED
    Member

    Hello AMrray, can you edit the required php file, to include this email validation capability, so my every form (current or future new forms i will create)gain this added extra capability?

    And later I will upload this php to my macform web folder.

    Thank you for the support.

    Posted 10 years ago #
  4. AMurray
    Pro Member

    If you're asking can I (personally) modify your files (where you say "can you edit the required Php file.....") then No, I am not a programmer, I don't know PHP coding.

    I'm not one of the Machform developers - my member level "pro member" (if that is where your assumption comes from) is only referring to my participation in the forum and I'm just a user of the product like most other forum members. The only developers of the product that regularly post answers are Redityo and Yuniar, that I recall.

    Appnitro may be able to provide you the code, but you'd have to raise this with them (perhaps with a private help-desk ticket request), as they may not see your question on the forum straight away but would respond quicker to a help request - http://www.appnitro.com/contact

    Posted 10 years ago #
  5. ConnecTED
    Member

    Thank you a lot, I have just send my request using contact form. Thank you for your time.

    Posted 10 years ago #
  6. williamansley
    Member

    @ConnecTED: You can modify the file \machform\includes\post-functions.php to add this functionality, but I don't recommend it, since the modifications will be overwritten if you ever upgrade. I no longer do this kind of customization to Machform. Having said that, perhaps this code may be useful to you and others. I am no longer maintaining this code and can supply no additional help with it; I am not much of a programmer - I put this together by guess and by gosh.

    You used to add this after line 45, but this may no longer be the case.

    //Email matching customization code: check for matching email addresses in various forms
    //The element ID is the same for all forms because each was made by duplicating and modifying another
    
    //IMPORTANT: Any new forms that need this validation will have to have their IDs added to this list
    
    $form_ids = array(3, 7, 9, 11, 12);
    
    //Email matching customization code: Test if email addresses match and set flag to false if they don't
    //This is checked later by custom code added to email validation
    $email_match = true;
    if (in_array($form_id, $form_ids)) {
       if($input['element_1'] != $input['element_2']){
    	$email_match = false;
       }
    }

    As noted in the comments, the above code will only work if the IDs of the email fields (element_1 and element_2, in the example above) are the same in all forms, which can be most easily done by creating one form and then duplicating and modifying it. Creating the array of form IDs isn't necessary if you want to use this with a single form or you have a range of forms with continuous ID number that you want to apply this to.

    You then need to add the following code to the email verification section of the same file. You used to add this after line 385, but this has almost certainly changed.

    //Email matching customization: addition validation for email can go here
    
    //Email matching customization: check to see if flag was set for email addresses not matching
    //In previous customization code lines added above
    if ($email_match == false) {
    	   $error_elements[1] = "Email addresses do not match.";
    	   $error_elements[2] = "Email addresses do not match.";
    }

    Unfortunately, the indenting of my code has been flattened out by the forum software, but it should still work, if you can adapt it to your particular situation. As I said, I have no time to provide any additional help with this and I will not respond to any such requests. This code is provided as is, etc.

    Posted 10 years ago #
  7. ConnecTED
    Member

    Thank you a lot for your time, I really appreciate it. :)

    Posted 10 years ago #
  8. williamansley
    Member

    You are welcome. Take a look at this old message thread for some additional information about code to add this functionality:

    http://www.appnitro.com/forums/topic/check-field-values-are-the-same?replies=9

    Posted 10 years ago #

RSS feed for this topic

Reply