Link to home
Start Free TrialLog in
Avatar of Victor  Charles
Victor CharlesFlag for United States of America

asked on

Help with masking textbox and validating entry

Hi,

I am masking a third party textbox control from wijmo, with "9" to enter only number, what do I need to include if I want to allow them to enter another character (i.e + or -).

Also when users finish entering data in the textbox and try to enter data in another textbox. How do I set an alert if they did not enter all the character in the previous textbox. For example my textbox should have 4 characters based on the following mask format 9999, if they only enter 545, I need trigger an alert that the entry is incomplete before they proceed to the next entry.

Thanks.

V.
Avatar of Gary
Gary
Flag of Ireland image

Are you using jquery?
Avatar of Victor  Charles

ASKER

No, I am using the code below, but it only works in a button click event, I need to activate the message without a button click event.

  Protected Sub Button184_Click(sender As Object, e As EventArgs) Handles Button184.Click
        Dim literal As String = C1FTH.Text
        Dim substring As String = literal.Substring(0, 1)
        If substring <> "+" And substring <> "-" Then
            '   Message
        End If
      If Len(C1FTH.Text) > 0 and Len(C1FTH.Text) < 4 then
       'Mesage
      End If

    End Sub
Hi,
You can use jQuery for validation.  There are maby plugins available, one of them beeing
http://digitalbush.com/projects/masked-input-plugin/
Hi Thank You for the link, instead of using a plug in, since the masked input control has an OnclientBlur event which activates when user leave the control, is it possible to use it to call a javascript code to validate the data from the client side? My office may have issues with me using other product due to potential license issues.

I believde the code that I wrote for the button click event would run on the server, therfore javasecript would be a better approach I think.

Thanks

V.
Hi,
If you want to call javascript code from code behind you have 2 porssibilities:
1. Inject the javascript code into the page using the code behind.
2. Use some existing client side code that will be called via certain client side events handling added as attribute(s).

Also, if you don't need a masked input box, you can use javascript regex vor validation.
I will need the masked input box, can you please send me an example of either possibilities or both. Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Eduard Ghergu
Eduard Ghergu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial