64 lines
1.8 KiB
JavaScript
Raw Normal View History

function fill() {
$("input#frm").each(function() {
var td_id = $(this).attr("name");
$("td#"+td_id).text($(this).val());
});
}
2013-06-12 13:57:30 +00:00
function validate() {
var allvals = true;
$("[required]").each(function() {
if(!$(this).val()) {
allvals = false;
$(this).addClass('brsr');
}
else { $(this).removeClass('brsr'); }
});
return allvals;
}
function isEmail(email) {
var emailval = true;
var regex = /^([a-zA-Z0-9_\.\-\+])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!regex.test(email.val())) {
emailval = false;
$(email).addClass('brsr');
}
else {
$(email).removeClass('brsr');
}
return emailval;
}
$(document).ready(function(){
validate();
isEmail($('[name=email]'));
});
$('[required]').blur(function(){
validate();
});
$('#dlg').dialog({ buttons: [
{ text: "Valider", click: function() {
fill();
$("[name='mailbody']").val($("#alwayshidden").html());
2013-06-12 13:57:30 +00:00
var values = $(this).find('form').serialize();
if (validate() && isEmail($('[name=email]'))) {
if ($('.loading').css('display')=='none') {
$('.loading').css('display', 'block');
$('.ui-dialog-content').css('overflow','hidden');
$(".ui-dialog-buttonpane button:contains('Valider')").button("disable");
}
else { $('.loading').css('display', 'none');}
$.post('/user/motpasse', values, function(data) {
$('#dlg').html(data);
$('pre').hide();
$('#vspace').height(50);
$('input#frm').attr("disabled", "disabled");
$(".ui-dialog-buttonpane button:contains('Valider')").hide();
2013-06-12 13:57:30 +00:00
});
}
}},
{ text: "Annuler", click: function() { $(this).dialog('close'); }}
] });