I was trying to automatically fill the form for ad report on mobile.de (Object to ad link). Filling fields (textarea for the description, inputs for email and phone number) with jQuery and submitting the form doesn't work as the fields are reset on submit. Filling them with jQuery works (you can see the change) but the field gets reset when a user focuses the field manually with the mouse.
I thought that some events were messing with the fields so I tried to block them but then I realized that not even jQuery triggers work on the fields (e.g. $().focus()
doesn't work).
How can I fill the form with jQuery so the values stay in the fields (without manipulating the post request)?
Edit:
$('#complain-link-center').click(function() {
setTimeout(function() {
// first radio click
$('#reasonName_CONTRADICTORY_VEHICLE_DATA').click();
// second radio click
$('#sourceOfDistrust_AD').click();
// this doesn't work
$('.cBox-body .g-col-4 textarea').focus();
// this works but you have to manually focus the field (stays populated on submit)
$('input#email').focus(function() {
$(this).val('email@example.com');
});
}, 100);
});
Edit2: I figured out that this page is developed with ReactJS so that's why it doesn't work with jQuery. Is there any possibility to manipulate ReactJS components with jQuery?