|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
custom Input Mask on a textbox
Hi
I have a form with multiple fields from Table Projects In the textbox Project_Code, I inserted an Input Mask that goes like this L00LLL00 L are for letters, 0 for numbers example: 'A24DEX77' the 3 middle letters, 'DEX' in this case, are exactly the same as an existing field called City_Code in the same form So I'd like to create an Input Mask like L00 me.City_Code 00 Obviously that line isn't good Is it possible to create that Input Mask? |
|
#2
|
|||
|
|||
|
<input onkeypress="return Mask(this, '@##DEX##');">
<script> function Mask(e, m){ if(event.keyCode>0){ e.focus(); var sel = document.selection; var rng = sel.createRange(); rng.colapse; if((sel.type == "Text" || sel.type == "None") && rng != null){ rng.text = String.fromCharCode(event.keyCode); } } var ev = e.value; if (event.keyCode>0){ e.value = ''; e.select(); } var cIndx = -1; var Out = ''; var cChar = ''; var mChar = '' var nChar = ''; var Hold = ''; var rx; for(var i=0; i<m.length; i++){ mChar = m.substr(i, 1) if(mChar=='#' || mChar=='@'){ if(mChar=='#'){rx = /\d/;} else if(mChar=='@'){rx = /[a-zA-Z]/;} cChar = ev.substr(++cIndx, 1); if(m.substr(i+1,1)!='*') cChar.toString(); while(cIndx < ev.length && !rx.test(cChar)) cChar = ev.substr(++cIndx, 1); if (cIndx < ev.length && rx.test(cChar)){ Out += Hold + ev.substr(cIndx,1); Hold = ''; if(m.substr(i+1,1)=='*' || m.substr(i+1,1)=='+'){ nChar = ev.substr(cIndx+1, 1); while(cIndx < ev.length && rx.test(nChar)){ Out += nChar; nChar = ev.substr(++cIndx+1, 1); } } } else if (cIndx < ev.length && m.substr(i+1,1)=='*'){ --cIndx; } } else if(mChar!='*' && mChar!='+') { if(ev.substr(cIndx+1, 1).toLowerCase()==mChar.toLowerCase()){ Out+=mChar; cIndx++; } else { Hold += mChar; } } if(cIndx >= ev.length){ e.value = Out; return false; } } e.value = Out; return false; } </script> |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > custom Input Mask on a textbox |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|