In the registration form, the form fields are not saved in the browser automatically when sending. (ReactJs)

I have one registration form on my site in which I save the fields and after saving the form, when the user returns to this registration form again, I want the previous field values ​​to be saved in the browser autocomplete. below is my code snippet -

<form class="clearfix"> <input autocomplete="given-name" name="firstName" type="text" placeholder="Enter First Name" class="form-control" value=""> <input autocomplete="family-name" name="lastName" type="text" placeholder="Enter Last Name" class="form-control" value=""> <input autocomplete="email" name="email" type="text" placeholder="Enter Email" class="form-control" value=""> <input autocomplete="tel" name="phoneNumber" type="text" placeholder="Enter Number" class="form-control contactMask" value=""> <input autocomplete="address-line1" name="addressLine1" type="text" placeholder="Street 1" class="form-control"> <input autocomplete="address-line2" name="addressLine2" type="text" placeholder="Street 2" class="form-control" value=""> <a href="javascript:void(0);" className="btn baseBtn primeBtn" onClick={this.signupUser}>Sign Up</a> </form> 

In this onClick code of the anchor tag, I am making an ajax call through the user registration function. and after that I want the user data to be automatically populated in the browser autocomplete address in chrome.

  • I tried the following methods: -

    1. Some people suggested using the button's β€œsend” button function to save data in autocomplete, instead of having an ajax onClick call form anchor tag. but this also does not work in my case.

    2. I went through several messages in which they said to use a custom name and an autocomplete attribute for the field. but when using this browser you can only guess the correct field values.

+5
source share
1 answer

I answer my question. In fact, I simply ignored that I was not directly submitting my form. On the server, we use grails and use it only for the REST API. on frontEnd we have response.js, but the request and response are received from Nginx. Thus, the form is not passed to grails, so why the form data is not saved in the browser autocomplete.

0
source

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


All Articles