PureEngage On-Premises

 View Only

Sign Up

  • 1.  Web chat - Make email field required

    Posted 07-23-2018 09:38
    Hello everybody,

    I'd like to request your help on a doubt we have, how can we set the email field as required in the registration form of the Genesys Widget Chat?

    I know that it is possible to add a validation on every field in the registration form but when doing this the other fields does not work properly.

    Please help on this.

    Regards.

    ------------------------------
    Aldo Castillo Aguirre
    Kaplan University
    ------------------------------


  • 2.  RE: Web chat - Make email field required

    Posted 07-24-2018 10:51
    Can you explain what you mean by the other fields don't work properly when you add validation?  Also, can you paste your JSON here that shows how you setup the inputs[] array?

    ------------------------------
    Jim Crespino
    Genesys - Employees
    ------------------------------



  • 3.  RE: Web chat - Make email field required

    Posted 07-24-2018 12:57

    Hello Jim, thanks for replying to this thread,

    Sure, please take a look at the JSON code snippet:


    Add a validation for input email field
    NOTE: <g class="gr_ gr_686 gr-alert gr_spell gr_inline_cards gr_disable_anim_appear ContextualSpelling ins-del" id="686" data-gr-id="686">The ft</g>() function highlights the required fields.

    The issue that I'm facing with this validation is that the pop-ups stating that the other fields are needed to start a chat session are not popping up, they will only pop up when there's something in the email field.


    Name required

    Am I missing a code validation or broke something?

    Regards.



    ------------------------------
    Aldo Castillo Aguirre
    Kaplan University
    ------------------------------



  • 4.  RE: Web chat - Make email field required

    Posted 07-24-2018 13:51
    The reason that the other fields aren't getting validate is that your validation function is only linked to the email field.  You will need to define a validation function for each field as covered in this article: https://developer.genesys.com/2017/11/27/genesys-widgets-customization-sidebar-and-customizable-chat-registration-form-i/

    Something like this should do the trick.  Please adapt each validate() function to your needs:


    inputs: [
    {
      id: "cx_webchat_form_firstname",
      name: "firstname",
      maxlength: "100",
      placeholder: "@i18n:webchat.ChatFormPlaceholderFirstName",
      label: "@i18n:webchat.ChatFormFirstName",
      type: "text",
      validateWhileTyping: false, // default is false
      validate: function(event, form, input, label, $, CXBus, Common) {
        if(input) {
          if (input.val())
            return true;
          else
            return false;
        }
        return false;
      }
    },
    {
      id: "cx_webchat_form_lastname",
      name: "lastname",
      maxlength: "100",
      placeholder: "@i18n:webchat.ChatFormPlaceholderLastName",
      label: "@i18n:webchat.ChatFormLastName",
      type: "text",
      validateWhileTyping: false, // default is false
      validate: function(event, form, input, label, $, CXBus, Common) {
        if(input) {
          if (input.val())
            return true;
          else
            return false;
          }
        return false;
      }
    },
    {
      id: "cx_webchat_form_email",
      name: "email",
      maxlength: "100",
      placeholder: "Made mandatory via validate",
      label: "@i18n:webchat.ChatFormEmail",
      type: "text",
      validateWhileTyping: false, // default is false
      validate: function(event, form, input, label, $, CXBus, Common) {
        if(input) {
          if (input.val())
            return true;
          else
            return false;
        }
      return false;
    }
    }]


    ------------------------------
    Jim Crespino
    Genesys - Employees
    ------------------------------



  • 5.  RE: Web chat - Make email field required

    Posted 07-24-2018 14:27
    Thanks for the advise Jim,

    It works but I'm still unable to see the alert message, I just read the post you suggested me and I found what we need: 

    If you want to do something more complex, you are of course allowed to do it – i.e. testing if the value looks like an email address, generate an alert/toast to notify the user, 

    Do you know if there's a way to use the existing alert message? or I should create another?

    Thanks!






    ------------------------------
    Aldo Castillo Aguirre
    Kaplan University
    ------------------------------



  • 6.  RE: Web chat - Make email field required
    Best Answer

    Posted 07-25-2018 13:05
    If you just return true/false, then the chat UI will display a generic message to the user that the field is required.  If you want a more descriptive message, for instance if the email address is populated but not properly formatted, then I would suggest that you look at displaying an Overlay widget that will display you specific message text and the user can dismiss it and then fix the problem.

    ------------------------------
    Jim Crespino
    Director, Developer Enablement
    Genesys
    https://developer.genesys.com
    ------------------------------