Can anyone send javascript code to validate the network mac address (eg. 02:41:6d:22:12:f1) It accepts value from 00:00:00:00:00:00 to ff:ff:ff:ff:ff:ff. On keypress event of textbox, I need to allow characters 0-9, a-f and : (colon). What I have so far is
macPattern = /^([0-9a-fA-F]{2}[:-]){5}[0-9a-fA-F]{2}$/i; With this I am able throw exception for ff:ff:ff:ff:ff:ff but I also need to throw an exception for 00:00:00:00:00:00. My pattern is not throwing an exception.
Could you please give me a pattern through which I should able to throw an exception for both ff:ff:ff:ff:ff:ff and 00:00:00:00:00:00.
ff:ff:ff:ff:ff:ffand00:00:00:00:00:00, and then if it is neither of those, run it through the regex?ff:ff:ff:ff:ff:ffand00:00:00:00:00:00, it would be much better to exclude those cases using ordinary programming logic as @ajp15243 suggested twice, rather than "could you please give me compltely pattern." P.S. Is someone telling you that you have to do it all in a single regular expression? If so, who and why? Is this homework? This definitely doesn't seem to meet any real-world standard for ensuring input is an actual MAC address.