Delete a specific field after clicking back in the browser or using history.go (-1)

I have a form with capacha, if capacha is entered incorrectly, after sending the page, "history.go (-1)" occurs, and all fields include the output of capacha back to the screen

right now I have js, which is clear that ... but now that I need it in several places, I want to know if it is possible to clear the form field after something is connected to the html form or what when -or

thanks

+4
source share
4 answers

Have you tried looking into the cache controlling the CAPTCHA image (or the page loading it)?

+1
source

I think it is a bad idea to use "history.go (-1)" and JavaScript in general. You should check the captcha on the server side and on the server side select this page that you should display? again with captcha or on.

0
source

I do not think this is only possible with html, some programming needs to be added.

You may have a js function called in the onload event of the document.

Function

may be like this:

 function resetfields() { $("input[type=text]").val(""); $("textarea").val(""); // if any textarea } 

And you can also use some ajax in this function to get new code every time.

you can put this function on your master / header page so that you do not need to copy it to all pages (for this you may need to make the selector more accurate).

0
source

Another option is that you can rename the form field each time you visit the page. Add a timestamp to the name. Thus, the browser will not autofill it. You may need to modify your code a bit to account for this.

0
source

Source: https://habr.com/ru/post/1304008/


All Articles