martes, 29 de mayo de 2012
JavaScript para validar formulario HTML
El siguiente código valida tres formularios, nombre,cuidad y lo más importante e-mail:
function validar() {
var name = document.getElementById('name');
var email = document.getElementById('e-mail');
var ciudad = document.getElementById('city');
if (name.value.length < 0 || name.value == null || name.value == "" || email.value.length < 0 || email.value == null || email.value == "" || ciudad.value.length < 0 || ciudad.value == null || ciudad.value == "") {
alert("Favor de llenar completamente el formulario.");
return false;
} else {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (!filter.test(email.value)) {
alert('Favor de proveer un email válido.');
email.focus;
return false;
} else {
//alert("1.");
return true;
}
}
alert("2.");
return false;
}
Este es el formulario:
form action="/subscribe" method="post" onSubmit=" return validar()" id="subForm"
label for="name" Nombre: input type="text" name="cm-name" id="name"
label for="vhjjij-vhjjij">Email: input type="text" name="cm-vhjjij-vhjjij" id="e-mail"
label for="Ciudad">Ciudad: input type="text" name="cm-f-mjjjdj" id="city"
input type="submit" value="Subscribirme"
viernes, 4 de mayo de 2012
Instalar MySQL,Apache2, PHP5 en Fedora 15 y Configurar un Sitio.
Instala paquetes de MySQL, Apache, PHP y su modulo para MySQL:
$ yum install mysql mysql-server
$ yum install httpd
$ yum install php php-mysql
Añade MySQL y Apache a los niveles de arranque 2,3 y 5:
$ chkconfig --levels 235 mysqld on
$ chkconfig --levels 235 httpd on
Asigna password usuario root a BD MySQL:
$ mysqladmin -u root password miPassword
Arranca Servicios MySQL y Apache:
$ /etc/init.d/mysqld start
$ /etc/init.d/httpd start
Crea un archivo de configuración de tu sitio con el siguiente cotenido:
$ cat /etc/httpd/conf.d/mysite.conf
ServerAdmin test@test
DocumentRoot /var/www/html/mysite
ServerName mysite
# Logging
ErrorLog /var/log/httpd/mysite-error-log
CustomLog /var/log/httpd/mysite-acces-log common
Añade las siguientes lineas al archivo /etc/httpd/conf/httpd.conf :
Listen 8080
NameVirtualHost *:8080
Y finalmente, Abre el puerto http 8080 y reinicia apache:
$ sudo semanage port -a -t http_port_t -p tcp 6666
$ sudo /etc/init.d/httpd restart
viernes, 9 de marzo de 2012
Glassfish server en Gentoo
Descarga y descomprime el glassfish correspondiente, en este caso optare por un zip file ya que el .sh me tronó:
# wget http://download.java.net/glassfish/3.1.2/release/glassfish-3.1.2.zip
# unzip glassfish-3.1.2.zip
Arranca el dominio default:
# ./bin/asadmin start-domain
Accede vía web por el puerto 4848:
https://148.229.13.29:4848
Para que te topes con el siguiente error/warning:
"Secure Admin must be enabled to access the DAS remotely"
Que se resuelve asignando un password al administrador,
# ./bin/asadmin change-admin-password
Habilitando el acceso remoto,
# ./bin/asadmin enable-secure-admin
Y finalmente, reiniciando el dominio:
# ./bin/asadmin enabl./bin/asadmin restart-domain
lunes, 23 de enero de 2012
Cuando Olvides tu Password de Civil en Gentoo
Arranca un livecd con gentoo preferentemente y monta la particion de root:# mount /dev/sda2 /mnt/gentoo
Chrootea en el nuevo entorno:# chroot /mnt/gentoo /bin/bash# env-update# source /etc/profile# export PS1="(chroot) $PS1"Cambia el password:# passwd userEntramos de nuevo a livecd, desmontamos y reinicio del sistema:# exitlivecd ~# cdlivecd ~# umount -l /mnt/gentoo/dev{/pts, /shm,}livecd ~# umount -l /mnt/gentoo/{/boot, /sys, /proc,}livecd ~# rebootPD: Supuestamente esto funciona tambien para root aplicando solo passwd.NO PUEDO MONTAR EL SISTEMA DE ARCHIVOS PORQUE ES UN LINUX LVM:# mount /dev/sda2 /mnt/gentoo# mount: unknown filesystem type 'LVM2 member'El siguiente comando muestra el estatus de nuestros LV's:# lvscanEl siguiente comando carga los dispositivos:# modprobe dm-modEl siguiente comando cambia los volumenes existentes a activos:# vgchange -ayAhora podemos montar el volumen ;)# mount /dev/vg_pictaaaa/lv_root
miércoles, 5 de octubre de 2011
Validar Curp con Java
public boolean validarCurp(String curp){
curp=curp.toUpperCase().trim();
return curp.matches("[A-Z]{4}[0-9]{6}[H,M][A-Z]{5}[0-9]{2}");
}
Implementación:
Boolean miCurp = validarCurp(txtCurp.getText());
if (miCurp){
System.out.println("TRUE");
}else{
System.out.println("False, CURP debe seguir el formato:
LLLL######LLLLLL##");
LLLL######LLLLLL##");
}
martes, 30 de agosto de 2011
PEAR
PHP Extensión and Application Repository -
Instalación. En distribuciones basadas en Debian:
$apt-get install php-pear
No olvidar incluír el path en php.ini:
include_path = "/etc/php5/pear"
Comandos.
$pear list
Instala o actualiza: $pear install,uninstall nombrePaquete
$pear install nombreArquivoPaquete.tgz
$pear search nombre
$pear info nombrePaquete
Muestra actualizaciones $pear list-upgrades
$pear upgrade-all
$pear help nombreComando
Instalar dependencias de un paquete:
$pear install -alldeps,-a nombrePaquete
XXX
viernes, 6 de agosto de 2010
Validar sólo Números con una Expresión Regular (Perl)
if($valor=~/^\d+$/){
print STDERR "valorIf:$valor\n";
}else{
print STDERR "valorElse:$valor\n";
}
^ indica que tiene que iniciar con un número
$ indica que tiene que terminar con un número
\d indica cualquier digito del 0-9
Por si se requiere:
\D indica cualquier caracter que no sea digito del 0-9
Suscribirse a:
Entradas (Atom)