167 lines
4.8 KiB
JavaScript
167 lines
4.8 KiB
JavaScript
|
|
|
|
$().ready(function(){
|
|
$("#statusmsg").hide();
|
|
|
|
$("#txtbda,#txteda").datepicker({
|
|
|
|
minDate:new Date(2018,7,23),
|
|
maxDate:new Date(2018,7,27)
|
|
});
|
|
|
|
$("#pais").select2({
|
|
data: data.paises,
|
|
placeholder: "Select Country",
|
|
width: "70%",
|
|
});
|
|
|
|
$("#roomtype").select2({
|
|
data: data.roomtypes,
|
|
placeholder: "Select Rooming Preference",
|
|
width:"70%",
|
|
minimumResultsForSearch: -1,
|
|
|
|
});
|
|
|
|
|
|
$('#registerform').on('submit',function(e) {
|
|
e.preventDefault();
|
|
});
|
|
$('#registerform').validate({
|
|
ignore: '',
|
|
rules: {
|
|
nombre: {
|
|
required: true,
|
|
minlength: 2
|
|
},
|
|
apellido: {
|
|
required: true,
|
|
minlength: 2
|
|
},
|
|
email:{
|
|
required: true,
|
|
email: true
|
|
},
|
|
invited:{required:true},
|
|
financiacion:"required",
|
|
letterinvited:"required",
|
|
|
|
|
|
},
|
|
messages: {
|
|
nombre: {
|
|
required: "Please enter your firstname",
|
|
minlength: "Your firstname must be at least 2 characters long"
|
|
},
|
|
apellido: {
|
|
required: "Please enter your lastname",
|
|
minlength: "Your lastname must be at least 2 characters long"
|
|
},
|
|
email: "Please enter a valid e-mail address",
|
|
invited: "Select one option please",
|
|
financiacion: "Select one option please",
|
|
letterinvited: "Select one option please"
|
|
|
|
|
|
},
|
|
submitHandler: function(form){
|
|
var formdata = $(form).serializeArray();
|
|
formdata.find(item => item.name === "pais").value = $("#pais").select2("data")[0].text;
|
|
formdata.find(item => item.name === "roomtype").value = $("#roomtype").select2("data")[0].text;
|
|
var parameters = $.param(formdata);
|
|
console.log(parameters);
|
|
},
|
|
errorElement: "em",
|
|
errorPlacement: function ( error, element ) {
|
|
// Add the `help-block` class to the error element
|
|
|
|
element.parents(".input-container").addClass("has-feedback");
|
|
var esradio = element.prop("type") == "radio";
|
|
var pariente;
|
|
if ( esradio ) {
|
|
pariente = element.parents(".form-group").children(".radioerror");
|
|
|
|
pariente.append(error);
|
|
error.css("color", "#a94442")
|
|
//element.parents(".form-group").children(".radioerror").append(error);
|
|
//element.parents(".radios").append(error);
|
|
|
|
} else {
|
|
error.addClass( "help-block" );
|
|
error.insertAfter( element );
|
|
}
|
|
if ( !element.next( "span" )[ 0 ] && !esradio )
|
|
$( "<span class='glyphicon glyphicon-remove form-control-feedback'></span>" ).insertAfter( element );
|
|
if(esradio)
|
|
element.parents(".form-group").children(".radioerror").prepend("<span style='color:#a94442;' class='glyphicon glyphicon-remove'></span>");
|
|
|
|
},
|
|
success: function(label,element){
|
|
var esradio = $(element).prop("type") == "radio";
|
|
var pariente;
|
|
if ( esradio ) {
|
|
pariente = $(element).parents(".form-group").children(".radioerror");
|
|
var iconstatus = $(pariente).children("span");
|
|
if (!$(pariente).children("span")[ 0 ])
|
|
pariente.preprend("<span style='color:#3c763d;' class='glyphicon glyphicon-ok form-control-feedback'></span>");
|
|
}
|
|
else if ( !$( element ).next( "span" )[ 0 ]){
|
|
$( "<span class='glyphicon glyphicon-ok form-control-feedback'></span>" ).insertAfter( $( element ) );
|
|
}
|
|
|
|
|
|
|
|
},
|
|
highlight: function ( element, errorClass, validClass ) {
|
|
var esradio = $(element).prop("type") == "radio";
|
|
var pariente;
|
|
if ( esradio ) {
|
|
pariente = $(element).parents(".form-group").children(".radioerror");
|
|
pariente.addClass("has-error").removeClass("has-success");
|
|
var iconstatus = pariente.children( "span" );
|
|
iconstatus.addClass( "glyphicon-remove" ).removeClass( "glyphicon-ok" );
|
|
iconstatus.css("color","#a94442");
|
|
}
|
|
else
|
|
$( element ).next( "span" ).addClass( "glyphicon-remove" ).removeClass( "glyphicon-ok" );
|
|
$( element ).parents( ".input-container" ).addClass( "has-error" ).removeClass( "has-success" );
|
|
|
|
},
|
|
unhighlight: function (element, errorClass, validClass) {
|
|
var esradio = $(element).prop("type") == "radio";
|
|
var pariente;
|
|
if ( esradio ) {
|
|
pariente = $(element).parents(".form-group").children(".radioerror");
|
|
pariente.addClass("has-success").removeClass("has-error");
|
|
var iconstatus = pariente.children( "span" );
|
|
iconstatus.addClass( "glyphicon-ok" ).removeClass( "glyphicon-remove" );
|
|
iconstatus.css("color","#3c763d");
|
|
|
|
}
|
|
else
|
|
$( element ).next( "span" ).addClass( "glyphicon-ok" ).removeClass( "glyphicon-remove" );
|
|
$( element ).parents( ".input-container" ).addClass( "has-success" ).removeClass( "has-error" );
|
|
|
|
}
|
|
|
|
});
|
|
|
|
var finan;
|
|
$('input:radio[name="financiacion"]').change(function(){
|
|
finan=true;
|
|
if($(this).is(':checked') && $(this).val() == "si"){
|
|
$("#detallefinan").show();
|
|
$("#detallefinan textarea").addClass("has-error");
|
|
}
|
|
else
|
|
$("#detallefinan").hide();
|
|
|
|
$('#sifinan').tooltip("hide");
|
|
$('#sifinan').tooltip("destroy");
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|