I've got a text input field on my website with id 'fieldone', like this: <input type="text" name="fieldone" id="fieldone" value=""> Code (markup): In this field, people may enter 5 words maximum seperated by comma's. So I build in a check if there are max. 5 words seperated by comma's, this check is triggered everytime a comma is entered. The check works great, but it still allows people to enter some words after the 5th comma. Is there a way to remove everything in the 'fieldone' textbox after the 5th comma?
If I understand you correctly, you can count the number of commas (triggered when a comma is entered) make sure the number of commas doesn't go over 4 If a fifth comma is entered simply return false (in the keydown callback).