A Pen by Jens Grochtdreis on CodePen.
Last active
October 8, 2019 13:43
-
-
Save jensgro/ddca09e6f6c37a62737a42de9a2db9b0 to your computer and use it in GitHub Desktop.
Vue-Test - Dingsdays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="app"> | |
<form> | |
<label for="email">Email-Adresse</label> | |
<input type="email" required name="email" id="email" @keyup="validate" /> | |
<button id="submit" :disabled="disabled">Abschicken!</button> | |
</form> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const app = new Vue({ | |
el: "#app", | |
data: { | |
email: "", | |
disabled: true, | |
buttonText: "mehr lesen" | |
}, | |
methods: { | |
validate(event) { | |
const input = event.target; | |
const validity = input.validity; | |
this.disabled = !validity.valid && !validity.valueMissing; | |
} | |
} | |
}); | |
// jQuery | |
/* | |
$(() => { | |
const $submit = $('#submit'); | |
const $email = $('#email'); | |
$email.keyup(() => { | |
$submit.prop( | |
'disabled', | |
$email.val().length === 0 || | |
!$email.prop('validity').valid | |
); | |
}) | |
}); | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.10/vue.min.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body {padding: 40px;} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment