• Resolved abyz12345

    (@abyz12345)


    Users can add locations on my Open User Map. When they add a location using the +, I’d like to validate their input. E.g. disallow certain characters, or set a maximum number. Is there any way I can add such validation to the form settings fields?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Daniel

    (@danielschoenherr)

    Hi @abyz12345,

    You can do this with the power of javascript.

    const input = document.getElementById('oum_location_title');

    if (input) {
    input.addEventListener('input', function () {
    const invalidCharPattern = /@/g;

    // Remove @ symbols if found
    if (invalidCharPattern.test(input.value)) {
    input.value = input.value.replace(invalidCharPattern, '');

    // Optional: Show a quick feedback message
    alert('The "@" symbol is not allowed in the location title.');
    }
    });
    }

    ☝️ This js snippet would prevent users from typing @ symbols into the title field (#oum_location_title).
    You can add this snippet to the Custom JS field under Open User Map > Settings > Advanced.

    I would recommend to use ChatGPT to adapt the script to your needs.

    Best regards,
    Daniel

    Thread Starter abyz12345

    (@abyz12345)

    Works great! Gemini assisted me in getting the required validation and auto-rewrites for each field. Very nice, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Validate user input new locations’ is closed to new replies.