How to allow all special characters in textbox only one time in JS?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghurox27
    New Member
    • Sep 2016
    • 2

    How to allow all special characters in textbox only one time in JS?

    Dear Programmers, please help me out in this scenario:-

    I want my textbox should accept only special characters only once.

    It means for example:

    It should not allow '%' symbol more than once.

    All the special characters should be allowed only once in my textbox in JS.

    Thanx Inadvance.
    Last edited by raghurox27; Oct 1 '16, 07:12 AM. Reason: To get Quick Response.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    you would first have to define what a "special character" is. then you would check on input if the put in character already exists in the textbox’ value.

    Comment

    • raghurox27
      New Member
      • Sep 2016
      • 2

      #3
      Ohkay Thank You for your reply sir!!

      But yesterday i was trying using RegEx. So Is it possible to restrict more than one same character in textbox using Regex?

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        you would only need the RegExp to figure out if a character is a special character. then you would use String.indexOf( ) for the test.

        Comment

        Working...