Prevent selection from being added

Tridem's Avatar

Tridem

02 Jul, 2012 11:33 AM

Is there a way to return false to any callback function to prevent a selction from being added?

Use case: client validation of emails added freely by the user.

My attempt:
selectionAdded: function(elem) {

return /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/.test(elem.contents().get(1).nodeValue);

}

Or do I have to remove the selection?

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac