• Resolved Benham Design

    (@benham-design)


    I am trying to write a script that will go into the additional setting tab that will force a text box to only allow 5 digits ie a zip code to be entered. I can’t seem to get it to work; here is what I have so far Text-686 is a required field. Any help would be appreciated.

    <script> document.addEventListener('wpcf7mailsent', function (event) { var formId = '5d7e827'; (event.detail.contactFormId == formId) { var inputValue = document.querySelector('form[id="' + formId + '"] input[name="text-686"]').value; // Check if the input value is exactly 5 digits if (!/^\d{5}$/.test(inputValue)) { alert('Please enter exactly 5 numbers in the "Shipping Zipcode" field.'); event.preventDefault(); // Prevent the form submission return false; // Stop further execution } } }, false); </script>
    
    

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Takayuki Miyoshi

    (@takayukister)

    Thread Starter Benham Design

    (@benham-design)

    @takayuki Miyoshi Thanks I read that and can’t make it work hence why I am posting to see if I can get help on the code that isn’t working

    Thanks

    Brian

    Thread Starter Benham Design

    (@benham-design)

    Takayuki, I was able to get additional code validation to work when adding my code directly to the functions.php file. But when I add any code to your additional settings tab nothing happens. I either misundstand what the additional settings tab code box is for or your plugin is broken when it comes to the additional setting tab.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Form validation help’ is closed to new replies.