-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added strict mode to validate-users.js
- Loading branch information
mxkmp29
authored and
mxkmp29
committed
Aug 10, 2016
1 parent
3461949
commit 6b3c046
Showing
3 changed files
with
65 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,64 +1,69 @@ | ||
window.onload = function() { | ||
var ajaxUrl = document.getElementById('ajax-validation').getAttribute('data-url'); | ||
!(function($){ | ||
"use strict"; | ||
$(document).ready(function(){ | ||
var ajaxUrl = document.getElementById('ajax-validation').getAttribute('data-url'); | ||
|
||
// check if username is already in database | ||
jQuery('#jform_username').change(function(){ | ||
var name = jQuery(this).val(); | ||
if(name.length){ | ||
jQuery.ajax({ | ||
type: 'POST', | ||
url: ajaxUrl + '&username=' + name | ||
}).done(function(data){ | ||
if(data.success){ | ||
// check if username is already in database | ||
$('#jform_username').change(function(){ | ||
var name = $(this).val(); | ||
if(name.length){ | ||
$.ajax({ | ||
type: 'POST', | ||
url: ajaxUrl + '&username=' + name | ||
}).done(function(data){ | ||
if(data.success){ | ||
var message = { | ||
'error' : [data.message] | ||
}; | ||
Joomla.renderMessages(message); | ||
} | ||
}); | ||
} | ||
}); | ||
// check if email is already in database | ||
$('#jform_email1').change(function(){ | ||
var mail = $(this).val(); | ||
if(mail.length) { | ||
$.ajax({ | ||
type: 'POST', | ||
url: ajaxUrl + '&email=' + mail | ||
}).done(function (data) { | ||
if (data.success) { | ||
var message = { | ||
'error': [data.message] | ||
}; | ||
Joomla.renderMessages(message); | ||
} | ||
}); | ||
} | ||
}); | ||
//check if emails are equal | ||
$('#jform_email2').change(function(){ | ||
var mail1 = $('#jform_email1').val(); | ||
var mail2 = $('#jform_email2').val(); | ||
if(mail1.length && mail2.length){ | ||
if(mail1 != mail2){ | ||
var message = { | ||
'error' : [data.message] | ||
'error' : [ Joomla.JText._('COM_USERS_PROFILE_EMAIL2_MESSAGE') ] | ||
}; | ||
Joomla.renderMessages(message); | ||
} | ||
}); | ||
} | ||
}); | ||
// check if email is already in database | ||
jQuery('#jform_email1').change(function(){ | ||
var mail = jQuery(this).val(); | ||
if(mail.length) { | ||
jQuery.ajax({ | ||
type: 'POST', | ||
url: ajaxUrl + '&email=' + mail | ||
}).done(function (data) { | ||
if (data.success) { | ||
} | ||
}); | ||
//check if password are equal | ||
$('#jform_password2').change(function(){ | ||
var pass1 = $('#jform_password1').val(); | ||
var pass2 = $('#jform_password2').val(); | ||
if(pass1.length && pass2.length){ | ||
if(pass1 != pass2){ | ||
var message = { | ||
'error': [data.message] | ||
'error' : [ Joomla.JText._('COM_USERS_FIELD_RESET_PASSWORD1_MESSAGE')] | ||
}; | ||
Joomla.renderMessages(message); | ||
} | ||
}); | ||
} | ||
}); | ||
//check if emails are equal | ||
jQuery('#jform_email2').change(function(){ | ||
var mail1 = jQuery('#jform_email1').val(); | ||
var mail2 = jQuery('#jform_email2').val(); | ||
if(mail1.length && mail2.length){ | ||
if(mail1 != mail2){ | ||
var message = { | ||
'error' : [ Joomla.JText._('COM_USERS_PROFILE_EMAIL2_MESSAGE') ] | ||
}; | ||
Joomla.renderMessages(message); | ||
} | ||
} | ||
}); | ||
}); | ||
//check if password are equal | ||
jQuery('#jform_password2').change(function(){ | ||
var pass1 = jQuery('#jform_password1').val(); | ||
var pass2 = jQuery('#jform_password2').val(); | ||
if(pass1.length && pass2.length){ | ||
if(pass1 != pass2){ | ||
var message = { | ||
'error' : [ Joomla.JText._('COM_USERS_FIELD_RESET_PASSWORD1_MESSAGE')] | ||
}; | ||
Joomla.renderMessages(message); | ||
} | ||
} | ||
}); | ||
} | ||
})(jQuery); | ||
|
||
|