Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/06/2012, 01:41
Avatar de emprear
emprear
Colaborador
 
Fecha de Ingreso: junio-2007
Ubicación: me mudé
Mensajes: 8.388
Antigüedad: 16 años, 10 meses
Puntos: 1567
Respuesta: Expresión Regular JS para detectar www

Código HTML:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <title>titulo</title>
  5. <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  6. <script type="text/javascript">
  7. //<![CDATA[
  8. /* script */
  9. function url_en_texto(campo){
  10. var elCampo = document.getElementById(campo).value;
  11. var coincide = elCampo.match( /(ftp|http|https):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/gi);
  12. if(coincide != null){
  13. alert('hay una url');
  14. }
  15. }
  16. //]]>
  17. </head>
  18. <div>
  19. <textarea id="texto" cols="30" rows="5"></textarea>
  20. <br />
  21. <button onclick="url_en_texto('texto');">verificar</button>
  22. </div>
  23. </body>
  24. </html>

Saludos
__________________
La voz de las antenas va, sustituyendo a Dios.
Cuando finalice la mutación, nueva edad media habrá
S.R.