Wednesday, March 28, 2012

Validate FCKeditor input for maximum characters

I need to validate input for maximum characters into a FCKeditor textbox. I've seen this question, and variations on it, posted all over the place but haven't come across any clean solutions. Off the top of my head I can think of only two approaches:

1. Do some server side validation for maximum characters and return an error message if entered > max OR

2. Truncate the entry so as not to exceed the SQL Server column size and just caption the text box.

#2 is fine with me though I don't know how to go about doing it. I would much rather do the #1 method. Can anyone suggest how I may get this done?

Thanks

OnSubmit or whenever you want to do your check:

if ( FCKEditor.value.length > maxLength){ e.Cancel =true; lblError.Text ="Your value input is too long, please edit it by removing " + FCKEditor.value.length - maxlength +" characters from your input."; lblError.Visible =true; }

No comments:

Post a Comment