Reputation:
The mobile version of Facebook allows the site to function without JavaScript.
I have JS disabled on my Chrome Android browser.
When I try to make a comment on a post, the POST button is initially grey AND disabled; however, when I type in anything it goes blue and becomes enabled.
How is this possible without JS?
Upvotes: 1
Views: 2998
Reputation: 207511
HTML5 validation and CSS
input:invalid {
background-color: #ffdddd;
}
form:invalid [type="submit"] {
background-color: #CCC;
color: #AAA;
}
<form>
<label>Enter a Name</label>
<input type="text" required/>
<br />
<br />
<label>Enter an email address:</label>
<input type="email" required/>
<input type="submit" />
</form>
----------
If you want it disabled, you can have two buttons and toggle their display
input:invalid {
background-color: #ffdddd;
}
form [type="submit"][disabled] {
display: none;
}
form:invalid [type="submit"][disabled] {
display: inline;
}
form:invalid [type="submit"] {
display: none;
}
<form>
<label>Enter a Name</label>
<input type="text" required/>
<br />
<br />
<label>Enter an email address:</label>
<input type="email" required/>
<input type="submit" />
<input type="submit" disabled="disabled" />
</form>
Upvotes: 5