Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211623
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:29:20+00:00 2026-06-07T10:29:20+00:00

I have a form and I do JavaScript validation function onsubmit : <form method="post"

  • 0

I have a form and I do JavaScript validation function onsubmit:

<form method="post" onsubmit="return validateForm(this.id)" action="<?php echo $PHP_SELF; ?>" enctype="multipart/form-data" id='addjournalinfoform' style='border:0px;width:90%' class="formular" >
 
    <fieldset>
        <legend>
        Journal
        </legend>
        <label>
            <span>* ISSN:</span><br />
            <input type='text' onfocusout="validateField('issn')" class='text-input' value="" name="issn" id="issn" style='width:30%'>
        </label>
   </fieldset>

</form>

and this is the function:

function validateForm(form)
{
    if(form=="addjournalinfoform")
    {
        alert('onSubmit');
        if($('#issn').val()=="")
        {
            $('#issnMsg').hide(500);
            $('#issnMsg .formErrorContent').html("* This field is required!<br />");
            $('#issnMsg').css('margin-left', $('#'+field).width()-20);
            $('#issnMsg').show(500);
            $('#issn').focus();
            $('html:not(:animated),body:not(:animated)').animate({scrollTop: $('#issn').offset().top-50}, 0);
            return false;
        }
        else
        {
            return true;
        }
        
    }
    return false;
}

The problem is even when the function returns false, the form is still submitted. What am doing wrong, and how to prevent the submit?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:29:23+00:00Added an answer on June 7, 2026 at 10:29 am

    In this line:

    $('#issnMsg').css('margin-left', $('#'+field).width()-20);
    

    The variable field is not defined.

    Uncaught ReferenceError: field is not defined

    You must learn how to debug your own applications, because you won’t get far without it. Read about using the Console in whatever browser you are using.

    You can find information about opening the console in your browser in this Webmasters.SE question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is what I have: <form name=myts method=post action=ts.php enctype=multipart/form-data onsubmit=return upuInit(this)> . .
I have a form below and validation html code <form name=rt_form id=rt_form method=post onSubmit=return
I have a form: <form name=char-add id=char-add action=added.php method=post onsubmit=charAddValidate()> <input type=text name=Name id=Name
I have a relatively simple HTML / JavaScript form. Such as this: <form method='POST'
I have a pretty straight-forward javascript form validation script written: function validateForm(){ var x=document.forms[contactForm][firstname].value;
I have JavaScript form validation functions like so: function validate_name(field) { if (field ==
Hello i have this form filling javascript: function onLine(code,nn) { document.writeform.bericht.value+=code; document.writeform.bericht.focus(); document.writeform.nickname.value+=nn; write1();
How do i introduce validation before remote_form_for submits? I have javascript function called validateForm()
I am doing some basic form validation. I have the following JavaScript function: function
i have problem in javascript email validation, I wrote code something like, //emp.php <form

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.