Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Apr 2019
    Thanked 0 Times in 0 Posts

    Weird behaviour of input fields - How to manipulate event listeners


    This is a weird one.
    I have purchased a booking plugin (wordpress) to add to a site.

    I cannot show the site I am working on, but here a demo from plugin developers

    Once you have chosen your date and time, you end up on a form with input fields.
    I was able to pre-fill this form with data that I could pass in the URL.

    My URL would look something like this: https://sports.wpamelia.com/?first=J...222222222#book

    But here is the problem:

    Even though I managed to use jQuery to pre-fill the input fields of the form, as soon as I click confirm the fields' content is erased and the error "Please enter... " appears for each of them.

    So again:

    STEP 1: I open the booking page with an URL containing data in the query string
    STEP 2: Using jQuery, I manage to pre-fill the form that appears after having chosen date and time
    STEP 3: I click "Confirm"

    RESULT: all the fields are empty and for each one the error message "Please enter first name" (etc..) appears

    I've messaged the plugin developers. Only answer was that there is indeed no functionality to take the data from the Query String into the form fields yet.


    1) How could I find out, with chrome inspector or other tools, what exactly is ignoring the content I pre-fill into the form?
    ---> I've tried things like "getEventListeners" in the chrome inpector's console, but I don't really see how to get information out of that

    2) Would anyone know what the issue is and how I could bypass it?
    ---> there is a lot of javascript from the plugin developers behind that and something is expecting manual entering of the data into the fields...
    ---> but even when trying to fake manual entering with things like
    $(this).trigger("change").val(function(i,val){return 'aaaa';});
    this didn't solve the problem....

    (If anyone is interested, I can post later my javascript/jQuery functionality to get the form fields pre-filled with data from Query String... interesting code as you have to wait until the fields appear for jQuery to recognise them..)

    Thanks so much for any help!


  2. #2
    Senior Coder xelawho's Avatar
    Join Date
    Nov 2010
    Thanked 705 Times in 700 Posts
    When you look at the inspector after filling in the fields does it have hidden fields which are also filled?

  3. #3
    New to the CF scene
    Join Date
    Apr 2019
    Thanked 0 Times in 0 Posts
    Thanks xelawho.

    Good point, but no... it seems that they are using javascript code to make sure that the text is really typed in manually (or the fact that you type in manually will add the data to the correct array in the code)..

    If you look up the links above to the demo you will see this form once you have added date and time to your booking and "continue".

    But you can test and see what I mean in doing the following:

    1) go to one of their demos on https://wpamelia.com/demos/

    --> let's take this one: https://consultant.wpamelia.com/

    2) ok, now go to "book appointment", choose a service, choose a date and time..
    --> you should end up on the form

    3) before you write anything! do this:

    - select the first field (First Name) with your inspector tool, then
    - select the second field (Last Name) with the inspector tool, and then
    - select the third (email) with the inspector tool

    4) Now, in the inspector console, do the following:

    - write `$0.value = '[email protected]'` ---> and click enter (this should fill the field), then
    - write `$1.value = 'someone'` ---> click enter (this should fill the last name), then
    - write `$2.value = 'someone'` ---> click enter (this should fill the first name)

    5) and now the fun! :

    - go into one of these fields and start writing... or
    - just click "Confirm" at the bottome

    --> do you see what is happening to the fields that you had filled before?

    That's what I am trying to avoid.. I want my auto-populated fields to be accepted ... but something is preventing it.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts