forked from elmau/empresa-libre
72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
|
|
|
|
webix.ui.datafilter.rowCount = webix.extend({
|
|
refresh:function(master, node, value){
|
|
node.firstChild.innerHTML = master.count();
|
|
}
|
|
}, webix.ui.datafilter.summColumn)
|
|
|
|
|
|
function validate_rfc(value){
|
|
rfc = value.trim().toUpperCase();
|
|
if ( rfc == ""){
|
|
webix.message({ type:"error", text:"El RFC no puede estar vacío" });
|
|
return false
|
|
}
|
|
|
|
if (rfc.length < 12 || rfc.length > 13){
|
|
webix.message({ type:"error", text:"Longitud incorrecta del RFC" });
|
|
return false
|
|
}
|
|
|
|
var start = 4;
|
|
//~ var tipo = $$("opt_tipo").getValue();
|
|
//~ if (tipo == 1 && value.length != 13){
|
|
//~ webix.message({ type:"error", text:"RFC debe ser de 13 caracteres" });
|
|
//~ return false
|
|
//~ }
|
|
//~ if (tipo == 2 && value.length != 12){
|
|
//~ webix.message({ type:"error", text:"RFC debe ser de 12 caracteres" });
|
|
//~ return false
|
|
//~ }
|
|
//~ var tipo = 1;
|
|
//~ if (tipo == 2){
|
|
//~ start = 3;
|
|
//~ }
|
|
//~ var rfc = value.toUpperCase();
|
|
if (rfc.length == 12){
|
|
start = 3;
|
|
}
|
|
var part = rfc.slice(0, start);
|
|
var re = new RegExp('[a-z&Ñ]{' + start + '}', 'i');
|
|
if (!part.match(re)){
|
|
webix.message({ type:"error", text: "El RFC tiene caractéres inválidos al inicio" });
|
|
return false
|
|
}
|
|
part = rfc.slice(-3);
|
|
re = new RegExp('[a-z0-9]{3}', 'i');
|
|
if (!part.match(re)){
|
|
webix.message({ type:"error", text: "El RFC tiene caractéres inválidos al final" });
|
|
return false
|
|
}
|
|
|
|
part = rfc.slice(-9, -3);
|
|
re = new RegExp('[0-9]{6}', 'i');
|
|
if (!part.match(re)){
|
|
webix.message({ type:"error", text: "Fecha inválida" });
|
|
return false
|
|
}
|
|
var month = parseInt(part.slice(-4, -2))
|
|
if (month == 0 || month > 12 ){
|
|
webix.message({ type:"error", text: "Fecha inválida" });
|
|
return false
|
|
}
|
|
var day = parseInt(part.slice(-2))
|
|
if (day == 0 || day > 31 ){
|
|
webix.message({ type:"error", text: "Fecha inválida" });
|
|
return false
|
|
}
|
|
|
|
return true
|
|
};
|