document ready function function registration on submit function preve

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
$(document).ready(function(){
$(function() {
$('#registration').on('submit', function(e){
e.preventDefault();
$('input[type=submit]').prop({
disabled: true,
value:"Подождите..."
});
$('input[type=submit]').blur();
var username = $('#signup_username').val();
var email = $('#signup_email').val();
var password = $('#signup_password').val();
var confirm = $('#signup_confirm').val();
var _token = $("input[name=_token]").val();
$.ajax({
type: 'post',
url: '',
dataType: 'json',
cache: false,
data: {
token:_token,
username:username,
email:email,
password:password,
confirm:confirm
},
success: function (response) {
$('input[type=submit]').prop({
disabled: false,
value:"Сосдать аккаунт"
});
if(response.fail) {
$.each(response.errors, function( index, value ) {
$('#'+index+'_error').empty().append(value);
$('#'+index).parent().addClass('form-group');
$('#'+index+'_signup').addClass('form-group has-error');
});
}
console.log(response);
}
});
return false;
});
});
});