6coloquio/js/app.js

85 lines
2.0 KiB
JavaScript

function showmsg(msgTxt,ok){
if(ok){
$("#statusmsg").removeClass("alert-danger");
$("#statusmsg").addClass("alert-success")
$("#statusmsg").html("<strong>Ok!</strong> " + msgTxt);
}
else{
$("#statusmsg").removeClass("alert-success");
$("#statusmsg").addClass("alert-danger")
$("#statusmsg").html("<strong>Error!</strong> " + msgTxt);
}
$("#statusmsg").show();
}
$(document).ready(function(){
$("#statusmsg").hide();
$("#header").load("snippets/header.html");
$(".sidebar").load("snippets/sidebar.html");
$('#contactform').submit(function(event){
$("#statusmsg").hide();
event.preventDefault();
var post = $.post('contact.php', $(this).serialize());
post.done(function(data){
data = $.parseJSON(data);
if(data.success){
showmsg(data.message,true);
}
else{
showmsg(data.message,false);
}
console.log(data)
});
post.fail(function(error){
console.log(error)
});
});
$("#detallefinan").hide();
$('input:radio[name="financiacion"]').change(function(){
if($(this).is(':checked') && $(this).val() == "si"){
$("#detallefinan").show();
$('#detallefinan textarea').prop('required',true);
}
else{
$("#detallefinan").hide();
$('#detallefinan textarea').prop('required',false);
}
});
$('#doctype').change(function(){
if(this.value == "C.I"){
$('#txtdocnro').attr('placeholder',"1234567-0");
}
if(this.value == "PSP"){
$('#txtdocnro').attr('placeholder',"ABA-11125-444");
}
if(this.value == "Tipo:"){
$('#txtdocnro').attr('placeholder',"Seleccion un tipo de documento");
}
});
$('#registerform').submit(function(event){
$("#statusmsg").hide();
event.preventDefault();
var post = $.post('register.php', $(this).serialize());
post.done(function(data){
data = $.parseJSON(data);
if(data.success){
showmsg(data.message,true);
}
else{
showmsg(data.errors,false);
}
console.log(data)
});
post.fail(function(error){
console.log(error)
});
});
});