Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-27-2013, 04:23 PM   PM User | #1
howard-moore
Regular Coder

 
Join Date: May 2008
Posts: 114
Thanks: 13
Thanked 0 Times in 0 Posts
howard-moore is an unknown quantity at this point
Form field check not working on first click?

Hi,

I have the following code used to check whether form inputs have been completed correctly:

Code:
<script language="JavaScript" type="text/javascript">
 <!--
function checkform ( form )
 {
   if (form.title.value == "") {
     alert( "Please enter an article TITLE." );
     form.title.focus();
     return false ;
   }
   if (form.intro.value == "") {
     alert( "Please enter and article INTRODUCTION." );
     form.intro.focus();
     return false ;
   }
   if (form.full.value == "") {
     alert( "Please enter an article FULL STORY." );
     form.full.focus();
     return false ;
   }
   return true ;
 }
 //-->
 </script>
The issue I have is that the two fields (intro and full) are textareas on which I am using the ckeditor text editor, and when I go to submit the form for the first time, it comes up saying that the 'intro' textarea has not got anything added. From removing the ckeditor add-on to the textarea I can see that this is causing the issue, but does anyone know of a workaround that may help?

Thanks,
Neil
howard-moore is offline   Reply With Quote
Old 01-27-2013, 04:40 PM   PM User | #2
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
if (form.full.value == "") {

Form validation of this pattern 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. Numeric values, such as zip codes and phone numbers, should be validated as such. Ditto email addresses. This topic has been covered many times before in this forum.


Moses died before he ever reached Canada. Then Joshua led the Hebrews in the battle of Geritol.
- Pupil's answer to Catholic Elementary School test.
__________________

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.
Philip M is offline   Reply With Quote
Old 01-27-2013, 04:53 PM   PM User | #3
howard-moore
Regular Coder

 
Join Date: May 2008
Posts: 114
Thanks: 13
Thanked 0 Times in 0 Posts
howard-moore is an unknown quantity at this point
Quote:
Originally Posted by Philip M View Post
if (form.full.value == "") {

Form validation of this pattern 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. Numeric values, such as zip codes and phone numbers, should be validated as such. Ditto email addresses. This topic has been covered many times before in this forum.


Moses died before he ever reached Canada. Then Joshua led the Hebrews in the battle of Geritol.
- Pupil's answer to Catholic Elementary School test.
The reason that I have this is because I only want the user to fill 'some' information (and I am not bothered as to what that content is). It is part of a CMS, which is also the reason that I use ckeditor for the textareas.
howard-moore is offline   Reply With Quote
Old 01-27-2013, 05:12 PM   PM User | #4
Philip M
Supreme Master coder!

 
Philip M's Avatar
 
Join Date: Jun 2002
Location: London, England
Posts: 17,037
Thanks: 197
Thanked 2,411 Times in 2,389 Posts
Philip M has a spectacular aura aboutPhilip M has a spectacular aura aboutPhilip M has a spectacular aura about
I am not familiar with ckeditor but you seem to have already identified that as the problem.
__________________

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.
Philip M is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:02 AM.


Advertisement
Log in to turn off these ads.