Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
Can WebMask allow any alpha character or a dash?
posted

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..

 

 

 

 

Parents
No Data
Reply
  • 24497
    posted

    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>

Children
No Data