*keypress >>if this.selstart = 6 >> nodefault >> if inlist(nKeyCode,asc("A"),asc("a"),asc("P"),asc("p")) >> This.value = this.value + upper(chr(nKeyCode))+"M" >> endif >>endifHope works. Not tested.
* Keypress of your textbox (time) LPARAMETERS nKeyCode, nShiftAltCtrl if this.selstart = 5 and between(nKeyCode,32,126) nodefault if inlist(nKeyCode,asc("A"),asc("a"),asc("P"),asc("p")) this.value = substr(this.value,1,5) + upper(chr(nKeyCode))+"M" this.selstart = 7 endif endif if this.selstart > 5 and between(nKeyCode,32,126) nodefault endifIf at position after second min digit (selstart=5) and key pressed is an alphanumeric (between..) then only let to press "A","a","P","p". Nodefault is to "absorb" other presses. Between check is necessary for disabling our code for backspace, del, arrows etc. (so it in fact should have a default value or "AM" or "PM"-user might just press enter there). Now if we intercept one of those keys, it will be AM or PM, so set value appropriately (this.value ...) and set selstart just after the "M". The second check is for absorbing alphanumeric passed selstart = 5.