Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

tiagomacul
Giga Sage

How to format mac addresses? / Como formatar o número do mac addresses?

function onLoad() {
	var field = g_form.getElement('IO:f6361262db53a7406931140314961999');
	
	function formatMAC(e) {
		var r = /([a-f0-9]{2})([a-f0-9]{2})/i;
		var str = e.target.value.replace(/[^a-f0-9]/ig, "");

		while (r.test(str)) {
			str = str.replace(r, '$1' + ':' + '$2');
		}

		e.target.value = str.slice(0, 17);
	}

	field.on('keyup', formatMAC); 
}

 

 

Observação: 

Para pegar o ID do elemento, utilize o inspecionar.

 

Author:

Tiago Macul

Heleno Martins

Know-More-Now-Logo.jpg

Update set planning changes / Update set Planejando e executando mudanças no ambiente.

http://regexlib.com

 

Comments
User674366
Tera Explorer

Thanks for sharing this.

Version history
Last update:
‎02-05-2019 10:39 AM
Updated by: