Skip to content

Instantly share code, notes, and snippets.

@aranajhonny
Created November 21, 2016 13:03
Show Gist options
  • Save aranajhonny/5710792c5f3d8572a35e8e88c92572ec to your computer and use it in GitHub Desktop.
Save aranajhonny/5710792c5f3d8572a35e8e88c92572ec to your computer and use it in GitHub Desktop.
<input pattern="^([JVEG]{1})-([0-9]{8})-([0-9]{1})$" title="El formato debe ser J-12345678-9" placeholder="J-12345678-9" onkeyup="this.value=this.value.toUpperCase()">
function crear_cliente(){ // funcion para la compra
//remove errors
$('.form-group').removeClass('has-error');
//validating form modals
if ($("#rif").val() === "") {
$('[name="rif"]').parent().parent().addClass('has-error');
}else{
if ($("#razon_social").val() === "") {
$('[name="razon_social"]').parent().addClass('has-error');
}else{
if ($("#telefono").val() === "") {
$('[name="telefono"]').parent().addClass('has-error');
}else{
if ($("#email").val() === "") {
$('[name="email"]').parent().addClass('has-error');
}else{
if ($("#direccion").val() === "") {
$('[name="direccion"]').parent().addClass('has-error');
}else{
//post ajax form serialize
$.ajax({
url : "?controller=clientes&action=crearforjson",
type: "POST",
data: $('#form').serialize(),
dataType: "json",
success: function(data)
{
swal(data.msj);
$('#modal-id').modal('hide');
$('.form-group').removeClass('has-error'); // clear error class
$('.help-block').empty()
},
error: function(jqXHR, textStatus, error)
{
swal(error);
$('#modal-id').modal('hide');
$('.form-group').removeClass('has-error'); // clear error class
$('.help-block').empty(); // clear error string
}
});
}
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment