
$(document).ready(function() { 
    var options = { 
        //target:        '#formulaire',   // target element(s) to be updated with server response 
        //beforeSubmit:  showRequest,   pre-submit callback 
        success:       showResponse,  // post-submit callback 
        url:       'save' 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
 
    // bind form using 'ajaxForm' 
    $("#bouton").click(function() {
    $('#formpersonnalise2').ajaxSubmit(options);
    return false;

});  
}); 

$(document).ready(function() {
	
	// Fonction permettant de gérer les éléments par défaut des select :
	// - si pas d'élément "selected" initialement, on ajoute une ligne vide, permettant de déclencher une erreur lors du submit
	// - si un élément "selected", on ne fait rien
	$(".cbbreset").each(function () {
	var std = $(this).html();
	if (std.indexOf('selected')==-1) {
		$(this).prepend("<option value='' selected='selected'>Choisissez...</option>");
	}
	});

	// Fonction permettant de gérer les éléments par défaut des select :
	$(".candidatures .row").eq(9).css("margin-top","-20px");

	$("#anne_dobtention_du_baccalauratid").mask("9999");
   $("#date_de_naissanceid").mask("99/99/9999");
	// Vérification des données saisies : 0-9 (et +)
	$(".verif_num").keypress(function (e)  
	{ 
	  if( e.which!=8 && e.which!=0 && e.which!=43 && e.which!=61 && e.which!=32 &&(e.which<48 || e.which>57))
	  {
	    return false;
      }	
	});

	// Vérification des données saisies : a-z,A-Z (et caractères accentués)
  	$(".verif_alpha").keypress(function (e) 
	{ 
	  if(e.which!=221 && e.which!=249 && e.which!=224 && e.which!=231 && e.which!=232 && e.which!=233 && e.which!=8 && e.which!=0 && e.which!=45 && e.which!=61 && e.which!=32 && (e.which<65|| e.which>90) && (e.which<97|| e.which>122))
	  {
	    return false;
      }
	});
	
	// Vérification des données saisies : a-z,A-Z (et caractères accentués)
  	$("input").keypress(function (e) 
	{ 
	  if(e.which==13)
	  {
	    return false;
      }
	});
	
 }); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
    alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
    alert('Vos données on été sauvegardées'); 
} 