Để bỏ qua xác thực HTML, bạn có thể xóa thuộc tính khi nhấp vào nút bằng JavaScript.
Uer removeAttribute () để xóa một thuộc tính khỏi mỗi phần tử phù hợp.
<!DOCTYPE html>
<html>
<body>
<form>
First Name: <input type = "text" id = "fname" value = "Amit" required>
<input type = "radio" onclick = "dislay('fname')"><br>
</form>
<script>
function display(id) {
document.getElementById(id).value = document.getElementById(id).removeAttribute('required');
}
</script>
</body>
</html>