1 /*********************************************************************************
2 * SugarCRM Community Edition is a customer relationship management program developed by
3 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Affero General Public License version 3 as published by the
7 * Free Software Foundation with the addition of the following permission added
8 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
9 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
10 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
17 * You should have received a copy of the GNU Affero General Public License along with
18 * this program; if not, see http://www.gnu.org/licenses or write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
23 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25 * The interactive user interfaces in modified source and object code versions
26 * of this program must display Appropriate Legal Notices, as required under
27 * Section 5 of the GNU Affero General Public License version 3.
29 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
30 * these Appropriate Legal Notices must retain the display of the "Powered by
31 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
32 * technical reasons, the Appropriate Legal Notices must display the words
33 * "Powered by SugarCRM".
34 ********************************************************************************/
37 function password_confirmation() {
38 var new_pwd=document.getElementById('new_password').value;
39 var old_pwd=document.getElementById('old_password').value;
40 var confirm_pwd=document.getElementById('confirm_pwd');
41 if (confirm_pwd.value != new_pwd)
42 confirm_pwd.style.borderColor= 'red';
44 confirm_pwd.style.borderColor='';
46 if (confirm_pwd.value != (new_pwd.substring(0,confirm_pwd.value.length)))
47 document.getElementById('comfirm_pwd_match').style.display = 'inline';
49 document.getElementById('comfirm_pwd_match').style.display = 'none';
51 if (new_pwd != "" || confirm_pwd.value != "" || old_pwd !="" || (document.getElementById('page') && document.getElementById('page').value=="Change"))
52 document.getElementById('password_change').value = 'true';
54 document.getElementById('password_change').value = 'false';
57 function set_password(form,rules) {
58 if(form.password_change.value == 'true'){
60 alert(ERR_RULES_NOT_MET);
64 if (form.is_admin.value != 1 && (form.is_current_admin && form.is_current_admin.value != '1')&& form.old_password.value == "" ){
65 alert(ERR_ENTER_OLD_PASSWORD);
69 if (form.new_password.value == "" ) {
70 alert(ERR_ENTER_NEW_PASSWORD);
74 if (form.confirm_pwd.value == ""){
75 alert(ERR_ENTER_CONFIRMATION_PASSWORD);
79 if (form.new_password.value == form.confirm_pwd.value)
82 alert(ERR_REENTER_PASSWORDS);
90 function newrules(minpwdlength,maxpwdlength,customregex){
92 var passwd = document.getElementById('new_password').value;
94 if(document.getElementById('lengths')){
95 var length =document.getElementById('new_password').value.length;
96 if((length < parseInt(minpwdlength) && parseInt(minpwdlength)>0) || (length > parseInt(maxpwdlength) && parseInt(maxpwdlength)>0 )){
97 document.getElementById('lengths').className='bad';
100 else{document.getElementById('lengths').className='good';}
104 if(document.getElementById('1lowcase')){
105 if(!passwd.match('[abcdefghijklmnopqrstuvwxyz]')){
106 document.getElementById('1lowcase').className='bad';
109 else{document.getElementById('1lowcase').className='good';}
113 if(document.getElementById('1upcase')){
114 if(!passwd.match('[ABCDEFGHIJKLMNOPQRSTUVWXYZ]')){
115 document.getElementById('1upcase').className='bad';
118 else{document.getElementById('1upcase').className='good';}
122 if(document.getElementById('1number')){
123 if(!passwd.match('[0123456789]')){
124 document.getElementById('1number').className='bad';
127 else{document.getElementById('1number').className='good';}
130 // One special character
131 if(document.getElementById('1special')){
132 var custom_regex= new RegExp('[|}{~!@#$%^&*()_+=-]');
133 if(!custom_regex.test(passwd)){
134 document.getElementById('1special').className='bad';
137 else{document.getElementById('1special').className='good';}
142 if(document.getElementById('regex')){
143 var regex = new RegExp(customregex);
144 if(regex.test(passwd)){
145 document.getElementById('regex').className='bad';
148 else{document.getElementById('regex').className='good';}
154 function set_focus() {
155 if (document.getElementById('error_pwd')){
156 if (document.forms.length > 0) {
157 for (i = 0; i < document.forms.length; i++) {
158 for (j = 0; j < document.forms[i].elements.length; j++) {
159 var field = document.forms[i].elements[j];
160 if ((field.type == "password") && (field.name == "old_password" )) {
162 if (field.type == "text") {
172 if (document.forms.length > 0) {
173 for (i = 0; i < document.forms.length; i++) {
174 for (j = 0; j < document.forms[i].elements.length; j++) {
175 var field = document.forms[i].elements[j];
176 if ((field.type == "text" || field.type == "textarea" || field.type == "password") &&
177 !field.disabled && (field.name == "first_name" || field.name == "name" || field.name == "user_name" || field.name=="document_name")) {
179 if (field.type == "text") {