function clean_hex(input, remove_0x) { input = input.toUpperCase(); if (remove_0x) { input = input.replace(/0x/gi, ""); } var orig_input = input; input = input.replace(/[^A-Fa-f0-9]/g, ""); if (orig_input != input) alert ("Warning! Non-hex characters (including newlines) in input string ignored."); return input; } function Convert() { var cleaned_hex = clean_hex(document.frmConvert.hex.value, document.frmConvert.chbSeparator.checked); var filename = document.frmConvert.filename.value; document.frmConvert.cleaned_hex.value = cleaned_hex; if (cleaned_hex.length % 2) { alert ("Error: cleaned hex string length is odd."); return; } var binary = new Array(); for (var i=0; i