Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Ajax validation with VueJS
new Vue({
el: '#app',
data: {
formInputs: {},
formErrors: {}
methods: {
submitForm: function(e) {
var form = e.srcElement;
var action = form.action;
var csrfToken = form.querySelector('input[name="_token"]').value;
this.$, this.formInputs, {
headers: {
'X-CSRF-TOKEN': csrfToken
.then(function() {
.catch(function (data, status, request) {
this.formErrors =;

This comment has been minimized.

Copy link

sadeghian92 commented Apr 1, 2017

Hi, this code has a problem with Firefox. the form variable will be undefined for Firefox browser.
I think you should change line 11 to this:
var form = || e.srcElement;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.