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
80
Does WebMaskEdit Have Change Input Direction Capability
posted

When researching masks, typically the explanation point flag will cause input to begin at the right rather than the left.  However the masked edit control does not support this flag. 

I need to mask my control to enter weight, height, temperature, and other vital signs...all of which have the number of digits to the left of the decimal point varying from two to three digits.  It would be nice to be able to begin on the right side so the user is not required to type a 098.6 for a 98.6 temperature with a mask of 999.9 (or even a 000.0 or ###.#, etc...).

 Does this control have a property that I am completely missing that lets me change input direction?

Thanks in advance for your help!

  • 24497
    posted

    Hi,

    That is correct WebMaskEdit does not support free entry text and on start sets predifined mask. It means that if caret on start at right side, then user will not be able to enter anything.

    If you need free edit mode when I would recommend to use WebTextEdit and filter entry. You may easily prevent any undesired entry, do various validations, etc. Below example allows for user to enter only digits or dot, validates if dot is entered, etc. You may add a lot of other checks.

    <script type="text/javascript">
    function
    WebTextEdit1_KeyPress(oEdit, keyCode, oEvent)
    {
     
    if(keyCode < 32) return;
     
    var digit = keyCode >= 48 && keyCode <= 57;
     
    var dot = keyCode == 46;
     
    var txt = oEdit.getText();
     
    if(!digit && !dot)
        oEvent.cancel =
    true;
     
    var caret = oEdit.getSelection();
     
    if(dot && caret < 2)
       oEvent.cancel =
    true;
     
    var hasDot = false;
     
    for(var i = 0; i < txt.length; i++)
       
    if(txt.charCodeAt(i) == 46)
           hasDot =
    true;
     
    if(dot && hasDot)
       oEvent.cancel =
    true;
     
    // etc, validations
    }
    </script>

    <igtxt:WebTextEdit ID="WebTextEdit1" runat="server" MaxLength="6">
     
    <ClientSideEvents KeyPress="WebTextEdit1_KeyPress" />
    </
    igtxt:WebTextEdit>