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

  • SEARCH
  • Home
  • 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 7675583
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:59:47+00:00 2026-05-31T16:59:47+00:00

Here is my Javascript formvalidator function: function companyName() { var companyName = document.forms[SRinfo][companyName].value; if

  • 0

Here is my Javascript formvalidator function:

function companyName() {
    var companyName = document.forms["SRinfo"]["companyName"].value;
    if (companyName == ""){
    return false;
    } else {
    return true;
    }
}

function companyAdd() {
    var companyAdd1 = document.forms["SRinfo"]["companyAdd1"].value;
    if (companyAdd1 == ""){
    return false;
    } else {
    return true;
    }
}

function companyCity() {
    var companyCity = document.forms["SRinfo"]["companyCity"].value;
    if (companyCity == ""){
    return false;
    } else {
    return true;
    }
}

function companyZip() {
    var companyZip = document.forms["SRinfo"]["companyZip"].value;
    if (companyZip == ""){
    return false;
    } else {
    return true;
    }
}

function enteredByName() {
    var enteredByName = document.forms["SRinfo"]["enteredByName"].value;
    if (enteredByName == ""){
    return false;
    } else {
    return true;
    }
}

function dayPhArea() {
    var dayPhArea = document.forms["SRinfo"]["dayPhArea"].value;
    if (dayPhArea == ""){
    return false;
    }
}

function dayPhPre() {
    var dayPhPre = document.forms["SRinfo"]["dayPhPre"].value;
    if (dayPhPre == ""){
    return false;
    } else {
    return true;
    }
}

function dayPhSub() {
    var dayPhSub = document.forms["SRinfo"]["dayPhSub"].value;
    if (companyAdd1 == ""){
    return false;
    } else {
    return true;
    }
}

function validateForm() {
        if (companyName() && companyAdd() && companyCity() && companyZip() && enteredByName() && dayPhArea() && dayPhPre() && dayPhSub()) {
            return true;        

        } else {
            window.alert("Please make sure that all required fields are completed.");
            document.getElementByID("companyName").className = "reqInvalid";
            companyName.focus();
            return false;
        }
    }

Here are all of my includes, just in case one conflicts with another (I am using jquery for their toggle()):

<script type="text/javascript" src="formvalidator.js"></script>
<script type="text/javascript" src="autoTab.js"></script>
<?php 
require_once('mobile_device_detect.php');
include_once('../db/serviceDBconnector.php');
$mobile = mobile_device_detect();

if ($mobile) {
        header("Location: ../mobile/service/index.php");
    if ($_GET['promo']) {
        header("Location: ../mobile/service/index.php?promo=".$_GET['promo']);
    }
}

?>
<script src="http://code.jquery.com/jquery-1.7.1.js"></script>

Here is my form tag with the function returned onSubmit:

<form method="POST" action="index.php" name="SRinfo" onsubmit="return validateForm();">

The validation works perfectly, I tested all fields and I keep getting the appropriate alert, however after the alert the form is submitted into mysql and sent as an email. Here is the code where I submit my POST data.

if($_SERVER['REQUEST_METHOD']=='POST') {
// Here I submit to Mysql database and email form submission using php mail()
  • 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-05-31T16:59:48+00:00Added an answer on May 31, 2026 at 4:59 pm

    It would seem to me that this line is likely blowing up:

    companyName.focus();
    

    The only definition I see for companyName is the function. You can’t call focus on a function.

    This blows up so the return false is never reached.

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

Sidebar

Related Questions

Here is my Javascript... <script type=text/javascript> function validator() { var x = parseInt(document.MyForm.textnuming.value); alert(x);
Here is the JavaScript function ChangeVol(id) { document.form.selectFS_devId.value = id; document.form.selectFS_currentNameSpace.value = ; document.form.submit();
here is javascript code: var test = { h : function (a) {return a;},
I try to do something pretty strait... getting php value to javascript here is
Here is javascript code (jquery) for adding a row of images: var tr =
So I have here a JavaScript stack built after this function: function Stack() //Creating
Possible Duplicate: >> in javascript Here: var num=10; console.log(num/2); num=4; console.log(num/2); It gives me
I need to use basic javascript here and I'm not well versed with it.
As an extension to this question here Linking JavaScript Libraries in User Controls I
I was going through Nicholas Zakas presentation on JavaScript here : http://www.slideshare.net/nzakas/writing-efficient-javascript (slide number:

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.