By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,501 Members | 2,768 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,501 IT Pros & Developers. It's quick & easy.

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

P: 2
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.
Oct 1 '16 #1
Share this Question
Share on Google+
3 Replies


Dormilich
Expert Mod 5K+
P: 8,639
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.
Oct 2 '16 #2

P: 2
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?
Oct 4 '16 #3

Dormilich
Expert Mod 5K+
P: 8,639
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.
Oct 4 '16 #4

Post your reply

Sign in to post your reply or Sign up for a free account.