Subversion Repositories portal2

Rev

Rev 585 | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*  emg - Energy Monitoring & Graphing
*  Copyright (C) 2006-2012 Romain Lievin
*
*  This program is free software; you can redistribute it and/or modify
*  it under the terms of the GNU General Public License as published by
*  the Free Software Foundation; either version 3 of the License, or
*  (at your option) any later version.
*
*  This program is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*  GNU General Public License for more details.
*
*  You should have received a copy of the GNU General Public License
*  along with this program; if not, write to the Free Software Foundation,
*  Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/


function addEvent(element, event, func)
{
    if (element.addEventListener)
        { // Si notre élément possède la méthode addEventListener()
        element.addEventListener(event, func, false);
    } else
        { // Si notre élément ne possède pas la méthode addEventListener() ie IE!
        element.attachEvent('on' + event, func);
    }
}

var password1 = document.getElementById('phpro_newpwd');
var password2 = document.getElementById('phpro_newpwd2');

var checkPasswordValidity = function()
{
        if (password1.value != password2.value)
        {
                password1.setCustomValidity('Les mots de passe doivent être identiques.');
        }
        else
        {
                password1.setCustomValidity('');
        }
};

addEvent(password1, 'change', checkPasswordValidity);
addEvent(password2, 'change', checkPasswordValidity);

var form = document.getElementById('passwordForm');

var submitCallback = function ()
{
        checkPasswordValidity();
        if (!this.checkValidity())
        {
                event.preventDefault();
                password1.focus();
                //password2.focus();
        }
}

addEvent(form, 'submit', submitCallback);