Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- $(function(){
- if(!Firstbit)
- Firstbit = {};
- if(!Firstbit.Project)
- Firstbit.Project = {};
- Firstbit.Project.ChangePassword = function(){
- this.form = $('#<?= $arResult["FORM_ID"] ?>');
- this.wrap = 'div[data-cid="' + this.fieldName + '"]';
- };
- Firstbit.Project.ChangePassword.prototype.init = function(){
- this.events();
- };
- Firstbit.Project.ChangePassword.prototype.events = function(){
- var self = this;
- var errors = false,
- message = 0;
- $(document).on('submit', self.form, function() {
- if (!$('#modal-window [name=USER_PASSWORD]').val()) {
- $('#modal-window [name=USER_PASSWORD]').addClass('_error').focus(function() {$(this).removeClass('_error');});
- errors = true;
- }
- if (!$('#modal-window [name=USER_PASSWORD_NEW]').val()) {
- $('#modal-window [name=USER_PASSWORD_NEW]').addClass('_error').focus(function() {$(this).removeClass('_error');});
- errors = true;
- }
- if (!$('#modal-window [name=USER_PASSWORD_NEW_CONFIRM]').val()) {
- $('#modal-window [name=USER_PASSWORD_NEW_CONFIRM]').addClass('_error').focus(function() {$(this).removeClass('_error');});
- errors = true;
- }
- if ($('#modal-window [name=USER_PASSWORD_NEW_CONFIRM]').val() != $('#modal-window [name=USER_PASSWORD_NEW]').val()) {
- $('#modal-window [name=USER_PASSWORD_NEW]').addClass('_error').focus(function() {$(this).removeClass('_error');});
- $('#modal-window [name=USER_PASSWORD_NEW_CONFIRM]').addClass('_error').focus(function() {$(this).removeClass('_error');});
- errors = true;
- }
- if (!errors) {
- $.post(self.form.attr('action'), self.form.serialize(), function (res) {
- var response = res.data;
- console.log(response);
- if (response && response.STATUS) {
- if (response.MESSAGES !== false ) {
- message = response.MESSAGES.length;
- }
- if (response.STATUS == 'OK') {
- window.location = window.location;
- }
- else {
- if (response.STATUS == 'ERROR' && message > 0) {
- $('#modal-window .form__errors-wrapper').empty().append('<div class="form__errors-container"></div>');
- while (message--) {
- $('#modal-window .form__errors-container').append('<span>' + response.MESSAGES[message] + '</span>');
- notificationOpen('message', {'message': response.MESSAGES[message]}, 10000);
- }
- }
- }
- }
- }, 'json');
- }
- errors = false;
- return false;
- });
- };
- var calculator = new Firstbit.Project.ChangePassword();
- calculator.init();
- });
- </script>
Add Comment
Please, Sign In to add comment