![Antiguo](http://static.forosdelweb.com/fdwtheme/images/statusicon/post_old.gif)
22/11/2005, 18:33
|
| | Fecha de Ingreso: octubre-2004 Ubicación: España
Mensajes: 894
Antigüedad: 20 años, 3 meses Puntos: 3 | |
Hola, nestin, y bienvenido al foro
Supongo que la única validación necesaria es que sean valores inferiores a 256, estén en hexadecimal y tenga los guiones.
Con expresiones regulares seguro que se hace de un tirón, pero no te puedo ayudar en eso.
Si no, a mano poco a poco:
function validaMac(x)
{
if (x.length) != 17 return false
if (x.charAt(3) != "-" return false
if (x.charAt(6) != "-" return false
if (x.charAt(9) != "-" return false
if (x.charAt(12) != "-" return false
if (x.charAt(15) != "-" return false
for (var i=0; i<17; i+=3)
{ if (parseInt(x.substr(i,i+2), 16)>255 return false }
}
Espero que con eso te apañes; quizás haya algo que pulir.
__________________ Angel :cool: |