Act12
Act12
<!DOCTYPE html>
<html lang="en">
<head>
<title>Form Validation</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.tailwindcss.com"></script>
</head>
<div class="mb-4">
</div>
<div class="mb-4">
</div>
<div class="mb-6">
</div>
</form>
<script>
$(document).ready(function () {
$("#myForm").submit(function (e) {
e.preventDefault();
$("#nameError").show();
isValid = false;
} else {
$("#nameError").hide();
if (!emailRegex.test(email)) {
$("#emailError").show();
isValid = false;
} else {
$("#emailError").hide();
if (password.length < 6) {
$("#passwordError").show();
isValid = false;
} else {
$("#passwordError").hide();
if (isValid) {
$("#myForm")[0].reset();
});
});
</script>
</body>
</html>
Output :