473,396 Members | 1,738 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Network Mac Address validation

Hi

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 to 9 , a to f , and : (colon).

On Clicking save button , script function should check the
format for valid mac address.

Text box length should be 17.

Pls post your replies.
Thanks in advance
somaskarthic
Sep 8 '06 #1
4 22558
Hi

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 to 9 , a to f , and : (colon).

On Clicking save button , script function should check the
format for valid mac address.

Text box length should be 17.

Pls post your replies.
Thanks in advance
somaskarthic
Sep 8 '06 #2
dlite922
1,584 Expert 1GB
Hi

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 to 9 , a to f , and : (colon).

On Clicking save button , script function should check the
format for valid mac address.

Text box length should be 17.

Pls post your replies.
Thanks in advance
somaskarthic
Here you go buddy...
Expand|Select|Wrap|Line Numbers
  1.  function isValidMacAddress(macAdd) 
  2.  {
  3.   var RegExPattern = /^[0-9a-fA-F:]+$/;
  4.  
  5.   if (!(macAdd.match(RegExPattern)) || macAdd.length != 17) 
  6.   {
  7.    alert("Invalid Media Access Control Address");
  8.   }
  9.   else
  10.   {
  11.    alert(macAdd + " is a valid Media Access Control Address");
  12.   }
  13.  }
  14.  
  15.  
  16.  
Jan 18 '08 #3
dlite922
1,584 Expert 1GB
sorry, that's JS, i don't know if you wanted that. but easily convertable to PHP.

See: preg_match
Jan 18 '08 #4
srenon
1
3 standard (IEEE 802) formats:

* 0a:1b:3c:4d:5e:6f
* 0a-1b-3c-4d-5e-6f
* 0a1b.3c4d.5e6f



Expand|Select|Wrap|Line Numbers
  1. <script type="text/javascript">
  2.  
  3.     teststr="0a:1b:3c:4d:5e:6f";
  4.  
  5.     regex=/^([0-9a-f]{2}([:-]|$)){6}$|([0-9a-f]{4}([.]|$)){3}$/i;
  6.  
  7.     if (regex.test(teststr)){
  8.         document.write("Valid mac address");
  9.     }
  10.     else{
  11.         document.write("Not a valid mac address");
  12.     }
  13.  
  14. </script>
  15.  
  16.  
Jul 16 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Alan Zhong | last post by:
when designing the address data entry webpage, i wonder... is there an online map/direction webpage that allow us to check if an address is validate? or auto-completes city names from the zip code?
25
by: Dynamo | last post by:
Hi The following script was taken from John Coggeshall's (PHP consultant) in his article on Zends site at http://www.zend.com/zend/spotlight/ev12apr.php // Get the email address to validate...
35
by: Mika M | last post by:
Simple question: Does Framework (1.1) contain any routine to check entered email-address is valid ? It's quite easy to make own code for that purpose, but why to do if Framework (1.1) contain...
0
by: Fur Data | last post by:
Hello, We are developing and providing the virtual market with an address validation add-on for 18 countries. A realtime prototype website can be visit at www.address-validation.com Via a...
0
by: jkhan | last post by:
Hi! I have problem which I shown in title and below as well. I have a Form name as Cancelation. The clientThread2() method is called on Form Load if I Close the Form and want to reload then the...
9
by: pbd22 | last post by:
Hi. I am getting the below error: Event Type: Error Event Source: PeskyService Event Category: None Event ID: 0 Date: 1/30/2008 Time: 5:49:10 PM User: N/A
8
by: cfmx2008 | last post by:
Hi All, I'm creating a form that it will parse a valid address in the address1 field from an address library to make sure this is a valid address. Here is the problem: The address is followed by...
4
by: JvC | last post by:
Does anyone have a good routine for EMail address validation? The one that I use is fairly primitive, and I need to beef it up. I have downloaded several from the web, and they all get screwed up...
1
by: jimatqsi | last post by:
I'm feeling like the 7th blind guy, the one feeling his way around the pile behind the elephant. I think what I am trying to do is very simple, but it's not turning out like that. I'm trying to do...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.