DEV Community

Discussion on: CSS Selectors Related to Form Control

Collapse
 
oahehc profile image
Andrew

Thanks a lot for the feedback.

  • Security is definitely an issue when doing the validation on the client-side. We should always validate the data on the backend server again. Thanks for reminding that.
  • For accessible, I should add aria-label for the button.
<button type="submit" aria-label="submit"></button>
  • Form submit event will be blocked if any of the input is invalid.
<form onsubmit={xxx}>...</form>

But If we use the button click event to submit the result, then we will need to add extra CSS to prevent the click event.

form:invalid > button {
  background: darkgray;
  pointer-events: none;
}
Collapse
 
youpiwaza profile image
max

Just keep in mind that anyone (with a little tech background) can edit html/css/js with browser inspector, or even forge requests from scratch ^^'

For the accessibility, I was thinking about add/removing the disabled attribute on the button, to inform that the user can't send the form if it isn't properly filled (especially for color blind people or those who uses readers) ; and prefer the submit event on form, instead of banking on the button :p

Anyway, still a great post !

Cheers