añado js
This commit is contained in:
+276
@@ -0,0 +1,276 @@
|
||||
//valida que un string solo haya numeros
|
||||
function soloNumeros(str1){
|
||||
var formatoNumerico = /^([0-9])+$/; //solo numeros
|
||||
return formatoNumerico.test(str1);
|
||||
}
|
||||
//********************************************************************************************************************
|
||||
|
||||
function esVacia(inputString)
|
||||
{
|
||||
var retValue = inputString;
|
||||
var ch = retValue.substring(0, 1);
|
||||
while (ch == " ") { // Check for spaces at the beginning of the string
|
||||
retValue = retValue.substring(1, retValue.length);
|
||||
ch = retValue.substring(0, 1);
|
||||
}
|
||||
|
||||
return (retValue=="")
|
||||
}
|
||||
|
||||
//********************************************************************************************************************
|
||||
function quitarUltimosSaltosLinea(campo)
|
||||
{
|
||||
//Eliminamos los saltos de linea que esten despues del ultimo elemento
|
||||
while (campo.value.indexOf("\r\n",campo.value.length-2)!=-1)
|
||||
campo.value=campo.value.substring(0, campo.value.length-2);
|
||||
}
|
||||
|
||||
//********************************************************************************************************************
|
||||
//valida Fechas de con formato dd-mm-aaaa
|
||||
function valorFecha(campo)
|
||||
{
|
||||
var resultado = true;
|
||||
if (campo.value != "")
|
||||
{
|
||||
var diaMesAno = (campo.value).split("-");
|
||||
|
||||
if(isNaN(diaMesAno[0]) || isNaN(diaMesAno[1]) || isNaN(diaMesAno[2]))
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno.length < 3)
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno[0].length > 2 || diaMesAno[1].length > 2 || diaMesAno[2].length > 4)//fecha!=00-00-0000
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno[2] < 1900) //año menor que 1900
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno[0] > 31 || diaMesAno[0] <= 0)//dia mayor que 31
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno[1] > 12 || diaMesAno[1] <= 0)//mes mayor que 12
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno[0] == 31 && (diaMesAno[1] == 4 || diaMesAno[1] == 6 || diaMesAno[1] == 9 || diaMesAno[1] == 11) )//dia 31 en meses de 30
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
else if (diaMesAno[1] == 2)
|
||||
{
|
||||
//febrero
|
||||
var isleap = (diaMesAno[2]%4 == 0 && (diaMesAno[2]%100 != 0 || diaMesAno[2]%400 == 0));
|
||||
if (diaMesAno[0] > 29 || (diaMesAno[0] == 29 && !isleap))
|
||||
{
|
||||
resultado = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!resultado)
|
||||
{
|
||||
respMalaValidacion("Debe introducir una fecha con el siguiente formato:\n dd-mm-aaaa", campo);
|
||||
}
|
||||
|
||||
return resultado;
|
||||
}
|
||||
|
||||
//********************************************************************************************************************
|
||||
|
||||
//Respuesta a una mala validacion de un campo
|
||||
function respMalaValidacion(msg, campo)
|
||||
{
|
||||
if (msg!='')
|
||||
{
|
||||
if (msg.substring(0, 3) == 'msg') //miramos si es un codigo de mensaje
|
||||
{
|
||||
alert(eval(msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if (campo.type == "text")
|
||||
{
|
||||
campo.select();
|
||||
}
|
||||
campo.focus();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/*--------------------------funcion marquee js -------------------------------*/
|
||||
|
||||
function marquee(a, b, noticia) {
|
||||
var width = b.width();
|
||||
var start_pos = a.width();
|
||||
var end_pos = -width;
|
||||
|
||||
var longitudNoticia = noticia.length;
|
||||
var longitudMarquee = 0;
|
||||
longitudMarquee = longitudNoticia * 7.4;
|
||||
var tiempo = 0;
|
||||
/*tiempo = longitudMarquee * 35; MAS RAPIDO */
|
||||
tiempo = longitudMarquee * 70;
|
||||
|
||||
|
||||
function scroll() {
|
||||
if (b.position().left <= -width) {
|
||||
b.css('left', start_pos);
|
||||
scroll();
|
||||
}
|
||||
else {
|
||||
time = (parseInt(b.position().left, 10) - end_pos) *
|
||||
(tiempo / (start_pos - end_pos)); // Increase or decrease speed by changing value 10000 (tiempo)
|
||||
b.animate({
|
||||
'left': -width
|
||||
}, time, 'linear', function() {
|
||||
scroll();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
b.css({
|
||||
'width': width,
|
||||
'left': start_pos
|
||||
});
|
||||
/*scroll(a, b);*/
|
||||
scroll();
|
||||
|
||||
b.mouseenter(function() { // Remove these lines
|
||||
b.stop(); //
|
||||
b.clearQueue(); // if you don't want
|
||||
}); //
|
||||
b.mouseleave(function() { // marquee to pause
|
||||
/* scroll(a, b); */
|
||||
scroll();//
|
||||
}); // on mouse over
|
||||
|
||||
}
|
||||
|
||||
/*--------------------------funcion marquee js -------------------------------*/
|
||||
|
||||
function marqueeRapido(a, b, noticia) {
|
||||
var width = b.width();
|
||||
var start_pos = a.width();
|
||||
var end_pos = -width;
|
||||
|
||||
var longitudNoticia = noticia.length;
|
||||
var longitudMarquee = 0;
|
||||
longitudMarquee = longitudNoticia * 7.4;
|
||||
var tiempo = 0;
|
||||
tiempo = longitudMarquee * 5;
|
||||
/*tiempo = longitudMarquee * 70; MAS LENTO */
|
||||
|
||||
|
||||
function scroll() {
|
||||
if (b.position().left <= -width) {
|
||||
b.css('left', start_pos);
|
||||
scroll();
|
||||
}
|
||||
else {
|
||||
time = (parseInt(b.position().left, 10) - end_pos) *
|
||||
(tiempo / (start_pos - end_pos)); // Increase or decrease speed by changing value 10000 (tiempo)
|
||||
b.animate({
|
||||
'left': -width
|
||||
}, time, 'linear', function() {
|
||||
scroll();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
b.css({
|
||||
'width': width,
|
||||
'left': start_pos
|
||||
});
|
||||
/*scroll(a, b);*/
|
||||
scroll();
|
||||
|
||||
b.mouseenter(function() { // Remove these lines
|
||||
b.stop(); //
|
||||
b.clearQueue(); // if you don't want
|
||||
}); //
|
||||
b.mouseleave(function() { // marquee to pause
|
||||
/* scroll(a, b); */
|
||||
scroll();//
|
||||
}); // on mouse over
|
||||
|
||||
}
|
||||
|
||||
//********************************************************************************************************************
|
||||
|
||||
//Pone la longitud de la noticia por css
|
||||
function tamanioNoticia(noticia)
|
||||
{
|
||||
var longitudNoticia = noticia.length;
|
||||
var longitudMarquee = 0;
|
||||
var strLongitud = "";
|
||||
|
||||
longitudMarquee = longitudNoticia * 7.4;
|
||||
|
||||
strLongitud = "" + (longitudMarquee + 130) + "px";
|
||||
|
||||
var css = '' +
|
||||
'.marquee {' +
|
||||
'width:' + strLongitud +
|
||||
'}' +
|
||||
'';
|
||||
|
||||
head = document.head || document.getElementsByTagName('head')[0];
|
||||
style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
|
||||
if (style.styleSheet){
|
||||
style.styleSheet.cssText = css;
|
||||
} else {
|
||||
style.appendChild(document.createTextNode(css));
|
||||
}
|
||||
|
||||
head.appendChild(style);
|
||||
|
||||
}
|
||||
|
||||
//********************************************************************************************************************
|
||||
|
||||
function mostrarPDF(nombrePDF) {
|
||||
var fileName = nombrePDF;
|
||||
document.getElementById('dialog').dialog({
|
||||
modal: true,
|
||||
title: fileName,
|
||||
width: 540,
|
||||
height: 450,
|
||||
buttons: {
|
||||
Close: function () {
|
||||
this.dialog('close');
|
||||
}
|
||||
},
|
||||
open: function () {
|
||||
var object = "<object data=\"{FileName}\" type=\"application/pdf\" width=\"500px\" height=\"300px\">";
|
||||
object += "If you are unable to view file, you can download from <a href = \"{FileName}\">here</a>";
|
||||
object += " or download <a target = \"_blank\" href = \"http://get.adobe.com/reader/\">Adobe PDF Reader</a> to view the file.";
|
||||
object += "</object>";
|
||||
object = object.replace(/{FileName}/g, "Files/" + fileName);
|
||||
document.getElementById('dialog').html(object);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//********************************************************************************************************************
|
||||
|
||||
function validarEmail( email ) {
|
||||
expr = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
|
||||
if ( !expr.test(email) ){
|
||||
return false;
|
||||
}else{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user