Skip to content

Instantly share code, notes, and snippets.

View AitorAlejandro's full-sized avatar

Aitor Alejandro Herrera AitorAlejandro

View GitHub Profile
@AitorAlejandro
AitorAlejandro / util.js
Last active May 17, 2021 10:08
Utilidades JavaScript
utils = {
//limpia un numero de comas, puntos, espacios en blanco, símbolos de dollar y euro
limpiaInteger : function (valor) {
nuevoValor = valor.replace(",",""); //quita comas
nuevoValor = nuevoValor.replace(".",""); //quita puntos
nuevoValor = nuevoValor.replace("$",""); //quita símbolo dollar
nuevoValor = nuevoValor.replace("€",""); //quita símbolo euro
nuevoValor = nuevoValor.replace(/ /g,''); //quita espacios en blanco
return nuevoValor;
@AitorAlejandro
AitorAlejandro / targetVSsrcElement
Created March 23, 2015 22:00
Averiguar el elemento que lanza la funcion - cross browser
//Ante dos elementos que llaman a la misma funcion:
document.getElementById('elem1').onchange = validarInput;
document.getElementById('elem2').onchange = validarInput;
function validarInput(e){
var oEvent = e || window.event;
var elem = oEvent.target || oEvent.srcElement;
//En el caso de que elem1 o elem2 sean inputs de un formulario se podria:
@AitorAlejandro
AitorAlejandro / emailing_template.html
Last active August 29, 2015 14:17
Esqueleto Email
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Plantilla básica</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</head>
<body leftmargin="0" marginwidth="0" topmargin="0" marginheight="0" offset="0" style="margin:0px 0px 0px 0px;padding:0px 0px 0px 0px;">
<!--
Se utiliza XHTML 1.0 Transitional, así que ojo con la sintaxis.
@AitorAlejandro
AitorAlejandro / noPageBack.js
Last active August 29, 2015 14:18
Evita el pageback cuando pulsamos backspace en un formulario
/*
Este script evita que al pulsar sobre la tecla retroceso cuando estamos sobre un submit, o input text que sea
readonly el navegador haga un pageback.
Compatible desde IE7
Como añade un listener al documento está desarrollado con javascript puro por eficiencia.
*/
(function(d){
if(d.addEventListener) {
d.addEventListener('keydown',noPageBack,false);
} else {
@AitorAlejandro
AitorAlejandro / buttonWithBreakLines.html
Created April 10, 2015 09:44
Input button con break line
<input type="button" value="Un botón&#x00A;muy&#x00A;alto">
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab"
width="200" height="16">
<param name="src" value="movie.mov" />
<param name="autoplay" value="true" />
<param name="pluginspage" value="http://www.apple.com/quicktime/download/" />
<param name="controller" value="true" />
<!--[if !IE]> <-->
<object data="movie.mov" width="200" height="16" type="video/quicktime">
<param name="pluginurl" value="http://www.apple.com/quicktime/download/" />
@AitorAlejandro
AitorAlejandro / embeddingWM.html
Created April 10, 2015 11:14
Windows Media embebido
<object type="video/x-ms-wmv"
data="movie.wmv"
width="320" height="260">
<param name="src"
value="movie.wmv" />
<param name="autostart" value="true" />
<param name="controller" value="true" />
</object>
@AitorAlejandro
AitorAlejandro / mfi.html
Created April 16, 2015 21:32
Multiple File Input
<form method="post" action="upload.php" enctype="multipart/form-data">
<input name='uploads[]' type="file" multiple>
<input type="submit" value="Send">
</form>
@AitorAlejandro
AitorAlejandro / datatoiframe.html
Created April 16, 2015 21:36
Post data to an iframe
<form action="iframe.php" target="my-iframe" method="post">
<label for="text">Some text:</label>
<input type="text" name="text" id="text">
<input type="submit" value="post">
</form>
<iframe name="my-iframe" src="iframe.php"></iframe>