Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener('DOMContentLoaded', function () {
- $.validator.setDefaults({
- highlight: function (element) {
- $(element)
- .closest('.form-group')
- .addClass('has-warning');
- },
- unhighlight: function (element) {
- $(element)
- .closest('.form-group')
- .removeClass('has-warning');
- }
- });
- $('#changeEmailForm').validate({
- rules: {
- password: {
- required: true,
- remote: {
- url: '/checkPassword',
- type: "GET",
- data: {
- password: function () {
- return $('#password').val();
- }
- }
- }
- },
- email: {
- required: true,
- email: true,
- remote: {
- url: '/checkEmailAtRegistering',
- type: "GET",
- data: {
- email: function () {
- return $('#email').val();
- }
- }
- }
- }
- },
- messages: {
- password: {
- remote: $.validator.format('Your password is incorrect')
- },
- email: {
- remote: $.validator.format('Email {0} exists in the database')
- }
- },
- submitHandler: function () {
- changeEmail()
- }
- });
- function changeEmail() {
- console.log("Event");
- $.ajax({
- type: 'PUT',
- url: '/changeEmail',
- data: {
- email: $('#email').val()
- },
- success: function (result) {
- console.log('function');
- }
- });
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement