Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
02-13-2013, 12:00 PM #1
- Join Date
- May 2008
- Thanked 0 Times in 0 Posts
CKEditor textarea validation problem
I have tried putting this to the CKEditor forum but they appear to blank it, so am coming here in desperation.
I use the following script to validate whether someone has added any content to a text area, which also uses the popular, open-source text editor, CKEditor. Without CKEditor it works absolutely fine, but when I use it, it does not recognise the text that has been added until the second click, and so displays the warning message even if text has been added to the textbox.
I have done lots of research on this but cannot understand any of the work-arounds. Can anyone offer any suggestions? My script is:
02-13-2013, 04:52 PM #2
- Join Date
- Jun 2002
- London, England
- Thanked 2,500 Times in 2,478 Posts
If you use this forum you ought by now to be aware of:-
The <!-- and //--> comment (hiding) tags have not been necessary since IE3 (i.e. since September 1997). If you see these in some published script it is a warning that you are looking at ancient and perhaps unreliable code.
b) alerts are considered to be obsolete and only useful for testing purposes. You should use DOM methods to display your messages to the user. You might wish to check for and reject dodgy characters such as #|!"'$£%&\/()=^<>*+ which are unlikley to appear in a title.
c) Form validation of the pattern if (document.formname.formfield.value == "") - that is blank - is barely worthy of the name, and virtually useless, as even a single space, an X or a ? will return false, that is pass the validation. A proper name may only contain letters, hyphen, space and apostrophe.
Numeric values, such as zip codes, phone numbers and dates, should be validated as such. Ditto email addresses. This topic has been covered many times before in this forum.
I would have thought that as a minimum you ought to strip leading/trailing/multiple spaces from the fields, and set a minimum length for the text.
Apart from those issues I don't see anything wrong with your code. But I know nothing of CKEditor.You mention work-arounds so presumably this problem is endemic.
Quizmaster: What is the English translation of the French word voiture?
Contestant: A tree.
Last edited by Philip M; 02-13-2013 at 05:03 PM.
All the code given in this post has been tested and is intended to address the question asked.
Unless stated otherwise it is not just a demonstration.