I have an in input required. As I am using input type="submit" it is working fine but I am using input type button. When I used input type button the input requirement doesn't work. Please help
When I used the code below with type submit the required is working
<script>
function validateForm() {
var x = document.forms["myForm"]["fname"].value;
if (x == "") {
alert("Name must be filled out");
return false;
}
}
</script>
<form name="add_name" id="add_name">
Name: <input type="text" name="fname" required>
<input type="submit" value="Submit">
</form>
But my form is as below. I am using input type button and the requirement is not working. How to solve it please.
<form name="add_name" id="add_name">
Name: <input type="text" name="fname" required>
<input type="button" value="Submit">
</form>