I have seen people do:
<form ..>
<button type='submit' value='Submit'>Sign Up</button>
</form>
Why do they need value='Submit'
if it isn't even submitted to the server? Is it for accessibility?
I have seen people do:
<form ..>
<button type='submit' value='Submit'>Sign Up</button>
</form>
Why do they need value='Submit'
if it isn't even submitted to the server? Is it for accessibility?
Forms can have more than one submit button. If you also give each button a name
, then you can use the value after submitting to see which one had been clicked.
<!DOCTYPE html>
<html>
<head>
<title>test submit</title>
</head>
<body>
<form action="#" method="get">
<button type='submit' name="clicked" value="thefirst">First</button>
<button type='submit' name="clicked" value="thesecond">Second</button>
</form>
</body>
</html>
If you submit this with the first button, the parameter posted will be clicked=thefirst
, while with the second one it will be clicked=thesecond
.
Of course in this case a much saner approach would be to give the buttons different names. but you get the idea.
All programmer use this. Because its is good understanding to another programmer to review already written code. It is not compulsory.