Subversion Repositories portal2

Rev

Blame | 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
*/


var ssl_crt = document.getElementById('form_certs_ssl_crt');
var ssl_key = document.getElementById('form_certs_ssl_key');
var ssl_ca = document.getElementById('form_certs_ssl_ca');

var checkFormValidity = function()
{
        var     ext_crt = ".crt";
        var     ext_key = ".key";
        var     ext_ca = ".crt";
       
        alert(ssl_crt.value);)
       
        if(ext_crt.test(ssl_crt.value))
        {
                password1.setCustomValidity('');
        }
        else
        {
                password1.setCustomValidity('You must select a valid CRT file.');
        }
};

ssl_crt.addEventListener('change', checkFormValidity, false);
ssl_key.addEventListener('change', checkFormValidity, false);
ssl_ca.addEventListener('change', checkFormValidity, false);

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

var submitCallback = function ()
{
        checkFormValidity();

        if (!this.checkValidity())
        {
                event.preventDefault();
                password1.focus();
        }
}

form.addEventListener('submit', submitCallback(), false);