Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Restricting 2 adjacent commas in text field

 
ashu srivastava
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic