<form>
<label for="email">メアド(必須)</label>
<input
type="text"
name="email"
id="email"
oninput="checkEmail()">
<button
type="submit"
id="button"
disabled>送信</button>
</form>
function checkEmail() {
const email = document.getElementById("email");
const button = document.getElementById("button");
if(email.value && email.value.length) {
// 入力欄が空👉disabled解除
button.disabled = false;
} else {
// 入力されている👉disabledを付与
button.disabled = true;
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.