Electric Type

Multimedia

About Us

News

Help

mask.htc source <property name= maskType />
<script language="jscript">

var realValue;
var formattedValue;

doBlur();

attachEvent("onfocus", doFocus);
attachEvent("onblur", doBlur);

function doFocus() {
  value=realValue;
}

function formatMoney(aValue) {
  var theFloat = parseFloat(aValue);
  var theMoney = (Math.round(theFloat * 100)) / 100;
  var theMoneyString = "$"+theMoney;

  return theMoneyString;
}

function formatDate(aValue) {
  var theMS = Date.parse(aValue);
  var theDate = new Date(theMS);

  return theDate.toLocaleString().slice(0,10);
}

function formatTime(aValue) {
  var theMS = Date.parse("1/1/80 "+aValue);
  var theDate = new Date(theMS);

  return theDate.toLocaleString().slice(10,23);
}

function format(aValue) {
  if (aValue == "") {
   return "";
  }

  if (maskType == "money") {
   return formatMoney(aValue);
  }
  if (maskType == "date") {
   return formatDate(aValue);
  }
  if (maskType == "time") {
   return formatTime(aValue);
  }
}

function doBlur() {
  realValue = value;
  value=format(value);
}

</script>