Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    May 2008
    Posts
    119
    Thanks
    13
    Thanked 0 Times in 0 Posts

    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

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,985
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    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.

  • #3
    Regular Coder
    Join Date
    May 2008
    Posts
    119
    Thanks
    13
    Thanked 0 Times in 0 Posts
    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.

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,985
    Thanks
    203
    Thanked 2,536 Times in 2,514 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •