Appnitro Software Forums » MachForm

compare two fields

(8 posts)

  1. I have a couple of elementary questions regarding MachForms. First, is it possible to compare two fields on a form? I have a field for email address and want to add a second field for the user to re-type the address (that part is done). I need to then compare the two fields and flag them with an error indicator if they do not match.

    Second question, can I auto fill a field based on the input of another field in the form? For example, I have a field for phone number input (required). I have a check box that to indicate that this number is a cell phone. If the check box is selected, I want to hide the cell phone number field and populate it with the previously entered phone number.

    Thank you in advance for your assistance.

    Richard

    Posted 2 years ago #
  2. FYI - Update:

    I found a previous post on the site that allowed me to handle question one. Code works great!

    Still need help with the second question.

    Thanks
    Richard

    Posted 2 years ago #
  3. Well, if you dig deep enough you'll eventually find what you are looking for. Resolved question two as well. Code is probably not the most elegant but it works!

    Thanks
    Richard

    Posted 2 years ago #
  4. Richard -

    I've looked for the compare two fields solution in order to confirm the correct email entry but couldn't find the earlier post you reference above. Would you be willing to share your solution?

    Thanks,

    Steve

    Posted 1 year ago #
  5. Thanks that was just what I was looking for.

    Now for a slightly different twist. Is it possible to have an email field on one form compare to an email field on another. For example, if I make users pre-register for an event but on the day of the event want them to log in using a new form which asks for their email. If it finds the email on the prior form it processes otherwise it gives them an error message referring them to the registration page.

    Something like this but I don't think I have the code quite right:

    if($form_id == 2){
    if($input['element_1'] != $form_id == 1, $input['element_1']){
    $process_result['status'] = false;
    $process_result['custom_error'] = 'You must register to attend!';
    }
    }

    Posted 1 year ago #
  6. OK I realize that my last post didn't quite understand the process. What I really want to have happen is to have the new email form field check against the database for the email that was previously entered. Is that possible?

    Posted 1 year ago #
  7. Yes, it's possible, you can change the code to be like this :

    if($form_id == 2){
    	//get email value  from another form
    	$query = "select count(1) is_register from ap_form_1 where element_1 ='".$input['element_2']."'";
    	$result = do_query($query);
    	$row_count = do_fetch_result($result);
    
    	if ( $input['element_2'] != '' && $row_count['is_register'] <= 0 ) {
    		$process_result['status'] = false;
    		$process_result['custom_error'] = 'You should register first!';
    	  }
    }

    In that code, I assume your form (form_2) will check email field (element_2) with another email field data (element_1) on another form (form 1) .You need to change those id's with yours before apply the code.

    Posted 1 year ago #

RSS feed for this topic

Reply

You must log in to post.