Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

JS and HEX Validation

0 views
Skip to first unread message

Grzegorz Miśkiewicz

unread,
Oct 19, 2007, 10:49:30 PM10/19/07
to perl-ja...@perl.org
Hi to all,

I'm trying to validate is string is hex:

function validate_mac (mac) {
var wzor = ^0[xX]([0-9a-fA-F]+)$;
var wynik = mac.match(wzor);
if(wynik == null) return false;
return true;
}

and use this function in this:

function validate_form_komputery ( form )
{
var msg = '';
if((form.ip1.value=='') || (form.ip2.value=='') || (form.ip3.value=='') ||
(form.ip4.value=='')) msg = '* Podany adres IP jest nieprawidłowy\n';
if((form.mac1.value=='') || (form.mac2.value=='') || (form.mac3.value=='')
|| (form.mac4.value=='') || (form.mac5.value=='') || (form.mac6.value==''))
msg += '* Popełniłeś błąd przy adresie MAC\n';

if(form.nazwa.value=='') msg += '* Nazwa hosta jest nieprawidłowa\n';
if(validate_mac(form.mac1.value)==false) msg += '* Podany adres mac nie
jest prawidłowy';
if(msg!=='') { alert (a.value+'\n'+msg); return false; }
}

and it not work at all, when i comment line:
if(validate_mac(form.mac1.value)==false) msg += '* Podany adres mac nie
jest prawidłowy';
rest of code work.

Where i have made a mistake ??

Best Regards,
Gregory Miskiewicz


0 new messages