최근 검색


최근 검색 없음

New Request Page: Match validation based off 2 custom fields

답변함


2021년 10월 02일에 게시됨

Hi All!

I'm surprised no one has asked this before - a simple request with what I assume to be a complicated solution.

Scenario: An end user would like to update their email address, and we would like the end-user to enter their new email address twice (two separate custom fields) - this is to reduce the possibility of entry errors.

Problem: Is there a way to validate that the two custom fields match exactly?
I assume this could be coded through either JSscript or by setting regex validation in the second custom field.

Any and all help would be appreciated! 


0

2

댓글 2개

image avatar

Christopher Kennedy

Zendesk Developer Advocacy

Hi Patrick,

There isn't a native feature that will perform this validation.  But you can accomplish this with custom JS in your Help Center theme that checks the custom field values before form submission.  Here's a sample demonstrating the concept that you can use as a starting point:

//replace <ticket_field_id> with the ID of each custom ticket field

var newRequestSubmitButton = $(".request-form input[type=submit]"),
      customFieldOne = $("#request_custom_fields_<ticket_field_id>"),
      customFieldTwo = $("#request_custom_fields_<ticket_field_id>");

  newRequestSubmitButton.on("click", function(e) {

  //if the two fields' values match, allow form submission to proceed
    if(customFieldOne.val()===customFieldTwo.val()){
      return;
    }

    //otherwise, stop the submission
    e.preventDefault();

    //code to display an error message to the user

  });

Best,

1


Christopher Kennedy

Amazing, thank you!

0


댓글을 남기려면 로그인하세요.

원하는 정보를 못 찾으셨나요?

새 게시물