I have created a login page with form tag, I want client side validation when user click Submit button, but nothing happens, Checkform method is not getting fired.
This is my code
<div>
<form class="login">
<p class="title">Log in</p>
<input type="text" class="form-control id="username" id="txtUsername" required>
<div class="invalid-feedback">
Please provide Username
</div>
<input class="form-control type="text" id="email" id="txtPass" required>
<div class="invalid-feedback">
Please provide Password
</div>
<br>
<button type="button" onclick="Checkform()">
<span class="state">Log in</span>
</button>
</form>
</div>
I have added bootstrap classes for validation and also a method in .ts file which should fire when I click on submit button
<div class="invalid-feedback">
Please provide Username
</div>
<div class="invalid-feedback">
Please provide Password
</div>
Checkform(){
var form = document.getElementsByClassName('login')[0] as HTMLFormElement;
if (form.checkValidity() === false) {
}
form.classList.add('was-validated');
}
How can I make client side validation for empty fields and fire a method when user click on Submit button ?
