+ 1
Submit form only if username not already exist Javascript
i have form code i know how to check username already exist or not by comparing with array. But the problem is that my form get submit in both case if my username is valid or not. so how do i make my field not valid and my form do not get submited when i enter the username that already exist in data storage. Check my javascript file in the given code https://code.sololearn.com/WFrHDCpul4SB/?ref=app
3 Réponses
+ 2
Use setCustomValidity method of the input element
https://code.sololearn.com/WJnWZZZlj8C1/?ref=app
https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement/setCustomValidity
+ 1
Calviղ thanks