Skip to content
Advertisement

Input validation – stop form from being clear out

I tried to create a sign up form where I need to validate if the the information entered is already exists in the database.

The code runs fine and can detect if the anything are already exists in the database. The problem is it will clear all the form when it detects anything exists in database.

For example in below picture I try to input an email that already exists in database but in the second photo, all the form fields are clear out

enter image description here

Is there any ways to prevent the form from being cleared out? Its not convenience for user to re-fill the form again.

Below is my code.

JavaScript

Advertisement

Answer

Use the following code

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement