hi,, I have tried to wrote code with ascii,I'm still not understand declared ascii in javascript.so this why I'm in this forum.to know the answer. I have one field, if I input field "05/01/" then I press "tab" from keyboard.I get year from this year, so the value in a field will be "05/01/2009". <script language="javascript"> function GetYear(){ var now=new Date(); year=now.getFullYear(); if(document.formname.field.value.length==6){ if(ascii==9){ field.value=field.value+year; } } } </script> Code (markup): I don't know how to declare it in javascript. and I'm still dont know this function where I must put. in onKeyUp or onKeyPress or onKeyDown or onBlur?? if anyone know the answer, please give me the answer and give me a suggestion where I must put that function or any suggestion. thanks sela
erm, i'd use onkeyup (keypress released). essentially, something like this (not tested but ought to be fine): var insertDate = function() { // code here to add the date }; window.onload = function() { document.getElementById("dateid").onkeyup = function(e) { if (e.keycode == 9 | e.which == 9) { // old netscape based browsers use .which // do something with tab. insertDate(); } // you probably need to handle shift+tab also - check e.shiftKey }; document.getElementById("dateid").onblur = function() { insertDate(); // they can use mouse to unfocus and not tab... }; }; PHP: