ojala me puedan ayudar gracias de antemano
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
![lloron](http://static.forosdelweb.com/fdwtheme/images/smilies/chillando.png)
| |||
Respuesta: como obligar a escribir un numero decimal Hola que tal, mira yo realizo eso usando jquery_masked, lo puedes descargar de aqui Tambien necesitas jquery: http://jquery.com/ Una vez descargados esos dos archivos tienes que poner entre <head> y </head> los siguientes scripts:
Código:
y a continuacion:<script type="text/javascript" src="jquery_1.8.0.js"></script> <script type="text/javascript" src="jquery.maskedinput.js"></script>
Código:
En donde peso es el nombre de tu campo y recibira un valor de tipo 1.80 por ejemplo<script type="text/javascript"> jQuery(function($){ $("#peso").mask("9.99"); }); </script> Mira aqui te dejo una forma completa y con mas opciones soportadas por jquery_masked
Código:
Espero que sea lo que andabas buscando. <!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>Documento sin título</title> <script type="text/javascript" src="jquery_1.8.0.js"></script> <script type="text/javascript" src="jquery.maskedinput.js"></script> <script type="text/javascript"> jQuery(function($){ $("#fecha").mask("99/99/9999"); $("#telefono").mask("(999) 999-9999"); $("#codigo").mask("99-9999999"); $("#serial").mask("aa*-99-9999"); $("#peso").mask("9.99"); }); </script> </head> <body> <p> <label>Fecha ("99/99/999") </label> <input id="fecha" type="text" name="date" /> <label><br /> <br /> Telefono ("(999) 999-9999") </label> <input id="telefono" type="text" name="telefono" /> <label><br /> <br /> Codigo ("99-9999999") </label> <input id="codigo" type="text" name="codigo" /> <label> <br /> <br /> Nro. Serie ("aa*-99-9999") </label> <input id="serial" type="text" name="serial" /> </p> <p>PESO <label> <input name="peso" type="text" id="peso" size="3" maxlength="3" /> </label> </p> </body> </html> |
| ||||
![]() Cita: muchas gracias, voy a catear el codigo gracias de nuevo
Iniciado por chuntaro18 ![]() Hola que tal, mira yo realizo eso usando jquery_masked, lo puedes descargar de aqui Tambien necesitas jquery: http://jquery.com/ Una vez descargados esos dos archivos tienes que poner entre <head> y </head> los siguientes scripts:
Código:
y a continuacion:<script type="text/javascript" src="jquery_1.8.0.js"></script> <script type="text/javascript" src="jquery.maskedinput.js"></script>
Código:
En donde peso es el nombre de tu campo y recibira un valor de tipo 1.80 por ejemplo<script type="text/javascript"> jQuery(function($){ $("#peso").mask("9.99"); }); </script> Mira aqui te dejo una forma completa y con mas opciones soportadas por jquery_masked
Código:
Espero que sea lo que andabas buscando.<!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>Documento sin título</title> <script type="text/javascript" src="jquery_1.8.0.js"></script> <script type="text/javascript" src="jquery.maskedinput.js"></script> <script type="text/javascript"> jQuery(function($){ $("#fecha").mask("99/99/9999"); $("#telefono").mask("(999) 999-9999"); $("#codigo").mask("99-9999999"); $("#serial").mask("aa*-99-9999"); $("#peso").mask("9.99"); }); </script> </head> <body> <p> <label>Fecha ("99/99/999") </label> <input id="fecha" type="text" name="date" /> <label><br /> <br /> Telefono ("(999) 999-9999") </label> <input id="telefono" type="text" name="telefono" /> <label><br /> <br /> Codigo ("99-9999999") </label> <input id="codigo" type="text" name="codigo" /> <label> <br /> <br /> Nro. Serie ("aa*-99-9999") </label> <input id="serial" type="text" name="serial" /> </p> <p>PESO <label> <input name="peso" type="text" id="peso" size="3" maxlength="3" /> </label> </p> </body> </html> |
Etiquetas: |