Is there a way to define a WebMask for a person's initials, that will allow the user to enter a dash (and only a dash) as the middle initial if they do not have a middle name?
I would like to restrict the middle character to be A-Z or a dash. but not allow a star, space, etc..
Hi,
WebMaskEdit does not allow to add or remove special characters to predefined flags (#, C, L, etc). If application needs to filter input, then it should process ClientSideEvents.KeyDown and cancel entry for undesired key. If there are no literal characters in mask, then application may use plain WebTextEdit with MaxLength property. Example, of implementation ClientSideEvents.KeyDown for WebMaskEdit which has default mask ("C" flags) but allows to enter only a-z, A-Z and -.
<script type="text/javascript">function WebMaskEdit1_KeyPress(oEdit, keyCode, oEvent){ //var caret = oEdit.getSelection(true); var a = 65, z = 90, A = 97, Z = 122, dash = 45; // same as //var a = 'a'.charCodeAt(0), z = 'z'.charCodeAt(0), etc. if(keyCode == dash) return; if(keyCode >= a && keyCode <= z) return; if(keyCode >= A && keyCode <= Z) return; oEvent.cancel = true;}</script>