*
The moose likes HTML, CSS and JavaScript and the fly likes Restricting 2 adjacent commas in text field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Restricting 2 adjacent commas in text field" Watch "Restricting 2 adjacent commas in text field" New topic
Author

Restricting 2 adjacent commas in text field

ashu srivastava
Greenhorn

Joined: Jun 25, 2011
Posts: 6
Hi All,
I have a requirement where user can put more than 1 values separated by commas. I am restricting all the special characters using javascript except comma, so user is able to enter comma in the field.

Now, I want to restrict user from entering more than 1 comma continuously,
Could anyone please suggest me how I should create javascript function to achieve this.

Thanks in advance.
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

when user enter character, just check the previous character. if it is comma show error
[another way is]
just take the value which is *entered* by user then split then just any value is "" or " " if it is then show error
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Restricting 2 adjacent commas in text field