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 


Reply via email to