Skip to content

Instantly share code, notes, and snippets.

@ramon-src
Last active July 26, 2019 17:40
Show Gist options
  • Save ramon-src/29043eb539a1db4085ff62889561d9e3 to your computer and use it in GitHub Desktop.
Save ramon-src/29043eb539a1db4085ff62889561d9e3 to your computer and use it in GitHub Desktop.
const app = new Vue({
el: '#app',
data: {
errors: [],
name: null,
usuario: null,
senha: null,
age: null,
movie: null
},
methods: {
checkForm: function (e) {
if (this.name && this.usuario && this.senha) {
return true;
}
this.errors = [];
if (!this.name) {
this.errors.push('O nome é obrigatório.');
}
if (!this.usuario) {
this.errors.push('O nome é obrigatório.');
}
if (!this.senha) {
this.errors.push('A senha é obrigatória.');
}
e.preventDefault();
this.formSubmit();
},
formSubmit() {
console.info('form');
let currentObj = this;
this.axios.post('http://localhost/formulario/action/actions.php', {
name: this.name,
idade: this.age,
usuaro: this.usuario,
senha: this.senha
}).then(function (response) {
currentObj.output = response.data;
}).catch(function (error) {
currentObj.output = error;
});
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment