Okay
  Public Ticket #3690704
Clarifications for Amelia Plugin Implementation
Closed

Comments

  • Dimitris Farganis started the conversation

    Could we add a rule to ensure that the phone number is definitely 10 digits long, to avoid any mistakes?

    • In the special fields, I have selected 'Text Area'. Can I have a placeholder inside it?
  •  602
    Stefan replied

    Hi Dimitris,

    Thanks for reaching out to us. This would require a custom validation script. Here is the one that you can use 

    <script>
    window.ameliaActions = {
      customValidation: function (success = null, error = null, data) {
        console.log('customValidation HOOK')
        console.log('------------')
        console.log(data)
        const customValidator = (rule, value, callback) => {
          let pattern = /^\d{10}$/;
     
          if (!pattern.test(value.replace(/\D/g,''))) {
            callback(new Error())
          } else {
            callback()
          }
        }
        data.rules.phone.push({required: false, message: 'The phone number must be 8 digits long', validator: customValidator, trigger: 'submit'})
      }
    }
    </script>

    Custom code needs to be applied to the page where the booking form is. Depending on what you're using (Gutenberg blocks, or some page builder), adding the CSS or JS can be done in a few different ways. 

    If you need help with adding custom CSS to the page, please take a look at this article.

    If you need help with adding custom JS to the page, please take a look at this article.


    Kind Regards, 

    Stefan Petrov
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia demo sites | Docs | Discord Community

    You can try wpDataTables add-ons before purchasing on these sandbox sites:

    Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables