make 'mac' field on an interface editable.
[plewww.git] / planetlab / nodes / interface.js
index 08bc28d..434333e 100644 (file)
@@ -80,6 +80,7 @@ function same_subnet (ip1,ip2,masklen) {
 }
 
 function networkHelper () {
+  window.console.log('networkHelper');
   var ip=$('ip').value;
   var nm=$('netmask').value;
 
@@ -103,6 +104,25 @@ function networkHelper () {
   $('broadcast').value=derived[1];
 }
 
+function macChecker(id, optional) {
+  var error= macCheckerSilent($(id).value);
+  if (error) {
+    Form.Element.focus($(id));
+    alert(error);
+  }
+}
+
+function macCheckerSilent(macAdd) {
+       var RegExPattern = /^[0-9a-fA-F:]+$/;
+       if (!(macAdd.match(RegExPattern)) || macAdd.length != 17) 
+       {
+               return "Invalid MAC Address";
+       } else {
+               return "";
+       }
+}
+
 /* check one */
 function subnetChecker (id, optional) {
   var error= subnetCheckerSilent([id,optional]);