![]() |
CKEditor textarea validation problem
Hi All,
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: Code:
<script language="JavaScript" type="text/javascript">Neil |
If you use this forum you ought by now to be aware of:-
a) <script language=javascript> is long deprecated and obsolete. Use <script type = "text/javascript"> instead (in fact also deprecated but still necessary for IE<9). 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. |
| All times are GMT +1. The time now is 12:05 AM. |
Powered by vBulletin®
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.