Thursday, 10 December 2015

auto-format-entered-date-onkeypress

  C# textbox.Attributes.Add("onkeyup", "javascript:return getDate(event);");

JavaScript


 function getDate(elem){
var elemVal = elem.value;
var elemId = elem.id;

switch(elemVal.length){
case 2:
elemVal = elemVal+"/";
break;
case 5:
elemVal = elemVal+"/";
break;
}
document.getElementById(elemId).value = elemVal;
}


No comments:

Post a Comment