เพื่อข้าม HTML validation ให้ลบ attribute เมื่อคลิกปุ่มด้วย JavaScript
ใช้ removeAttribute() ลบ attribute จาก matched elements
<!DOCTYPE html>
<html>
<body>
<form>
First Name: <input type="text" id="fname" value="Amit" required>
<input type="radio" onclick="display('fname')"><br>
</form>
<script>
function display(id) {
document.getElementById(id).removeAttribute('required');
}
</script>
</body>
</html>