scrimba
Preview
Module Project Part 3
Go Pro!Bootcamp

Bootcamp

Study group

Collaborate with peers in your dedicated #study-group channel.

Code reviews

Submit projects for review using the /review command in your #code-reviews channel

Module Project Part 3
AboutCommentsNotes
Module Project Part 3
Expand for more info
index.html
run
preview
console
<html>
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
</head>
<body>

<!-- Let's add Vue here -->
<div id="app">

<h1>Contact Form</h1>

<p style="color: red;">{{ error }}</p>

<form method="post" action="#">
<div>
<label for="name">Name</label>
<input name="name" id="name" v-model="form.name" />
</div>
<div>
<label for="email">Email</label>
<input name="email" id="email" v-model="form.email" />
</div>
<div>
<label for="message">Message</label>
<textarea name="message" id="message" v-model="form.message"></textarea>
</div>

<button @click.prevent="validateForm">Send Form</button>
</form>

<h2>Form Details</h2>

<p><strong>Name</strong> {{ form.name }}</p>
<p><strong>Email</strong> {{ form.email }}</p>
<p><strong>Message</strong> {{ form.message }}</p>

</div>

<script>
var app = new Vue({
el: '#app',
data: {
form: {
name: '',
email: '',
message: '',
},
error: '',
},
methods: {
validateForm: function () {
if (this.form.name.length && this.form.email.length && this.form.message.length) {
return this.error = 'Form Sent!';
}

return this.error = 'Invalid Form';
}
}
});
</script>
</body>
</html>
Console
index.html
-5:12