Link to home
Start Free TrialLog in
Avatar of wasabi3689
wasabi3689Flag for United States of America

asked on

MAC address format

I want my input MAC address (always 12 charators) as the following

1. xx:xx:xx:xx:xx:xx ( separated with : )
2. xx-xx-xx-xx-xx-xx ( separated with - )
3. xx.xx.xx.xx.xx.xx ( separated with . )
4. xxxxxxxxxxxx ( no separated  )
5. xxxxxxxxxx-xx ( last two charators separated with -)

The output always is  xx:xx:xx:xx:xx:xx ( separated with : )

Here is my code

in my jsp file

<input id="txtMAC" type="text" name="MACAddress" size="17"  maxlength="25" onchange="toggleVisibility(2);">
            <br>

in my java file


     MyMAC = MyMAC.replaceAll("(\\w{2})", "$1:");
     MyMAC = MyMAC.substring(0, MyMAC.length() - 1);
     

I want to know how I edit my code so that the jsp accept the input format but the output always xx:xx:xx:xx:xx:xx ( separated with : )
ASKER CERTIFIED SOLUTION
Avatar of Ajay-Singh
Ajay-Singh

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of wasabi3689

ASKER

Do I still need my these two lines?


     MyMAC = MyMAC.replaceAll("(\\w{2})", "$1:");
     MyMAC = MyMAC.substring(0, MyMAC.length() - 1);
Avatar of Ajay-Singh
Ajay-Singh

Yes. after that line