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 4015556
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:38:00+00:00 2026-05-20T09:38:00+00:00

I am currently working on JavaScript. This is what I have so far.. <script

  • 0

I am currently working on JavaScript. This is what I have so far..

     <script type="text/javascript">

     function formCheck(){
      var emailFilter=/^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-   Z0-9]{2,4})+$/;
    if (document.form.frmName.value==''){
    alert('Please enter your name');
    document.form.frmName.focus();
    document.getElementById("reqName").style.fontWeight="bold";
    return false;  
  }
      if (!(emailFilter.test(document.form.frmEmail.value))){
    alert('Please enter your email address correctly');
    document.form.frmEmail.focus();
    document.getElementById("reqEmail").style.fontWeight="bold";
    return false;
    }
    return true;
    } 
     function submitForm() [
     if (document.forms[0].firstName.value==""
     || document.forms[0].lastName.value=="") {
     window.alert("You must enter your first and last names!");
     return false;
      }
       else
     return true;
      }
   </script>
   </head>
   <body>
   <h2>**RSVP to my Party**</h2>
    <form action="myform" method="post" name="form" onsubmit="return formCheck()">
   <table>
  <tr>
      <td><span id="reqName"> First Name:</span></td>
      <td><input type="text" name="frmName"></td>
  </tr>
  <td><span id="reqName"> Last Name:</span></td>
      <td><input type="text" name="frmName"></td>
  </tr>
  <td><span id="reqName"> Number of Guest:</span></td>
      <td><input type="text" name="NumberofGuest"></td>
  </tr>
  <td><span id="reqName"> Time Arriving:</span></td>
      <td><input type="text" name="TimeArriving"></td>
   </tr>
  <tr>
     <td><span id="reqEmail"> Email:</span></td>
     <td><input type="text" name="frmEmail">
<input type="submit" value="Send" class="submit" /></td>
  </tr>
<tr>
  <td><span id=Submit"><input type="Submit" value="Submit" /></td>
  <td><span id="reset"><input type="reset" value="Start Over" /></td>
</tr>

  </table>
  </form>

  </body>
  </html>

I am getting a little confused I need to get it where each code to verify that the users have enter the data into all the fields. Now do I take each field and make them each have a submit button for them to read that? I know the email one works right.

  • 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-20T09:38:01+00:00Added an answer on May 20, 2026 at 9:38 am

    in your form html, call the submitForm() function:

    <form action="myform" method="post" name="form" onsubmit="return submitForm();">
    

    Then in your submitForm() function, call all the testing functions:

    function submitForm()
    {
        if (document.forms[0].firstName.value==""
            || document.forms[0].lastName.value=="") 
        {
            window.alert("You must enter your first and last names!");
            return false;
        }
        else
            // this is short for 'if nameCheck() == true && whateverCheck == true && ...'
            return formCheck() && nameCheck() && whateverCheck();
      }
    

    Remark: If the user made several mistakes, you must modify the checking call to directly find all mistakes like this:

        //...
        else
        {
            var allOk = true;
            allOk = formCheck() ? allOk : false;
            allOk = nameCheck() ? allOk : false;
            allOk = whateverCheck() ? allOk : false;
    
            return allOk;
        }
    

    Inside of each testing function, you can modify the field that’s being tested to show errors in the user’s input, e.g. by changing the inputLabel.style.color='red'.

    Edit:

    You should create a single, simple function for each field type you want to test.
    Typical field types for input type="text" are:

    • numeric field (e.g. age)
    • general text field (e.g. name, street, profession, …)
    • specific data fields (examples:)
      • zip code
      • date
      • time
      • ip address
      • email

    This way you will probably be able to use the same function for first and last name instead of creating two separate functions. That also means you can take them with you to your next project instead of needing to program everything again…

    These testing functions will take an object (i.e. an input field) and return a boolean:

    function testMyNameTextField(var testfield)
    {
        // check if testfield isn't null and is valid
    
        var nameTextFilter = /someregexp/;
        var everythingIsOk = (testfield.value != '') && (nameTextFilter.test(testfield.value));
        testfield.style.borderColor = everythingIsOk ? '' : 'red';
        return everythingIsOk;
    }
    

    You can of course separate the testing and the invalid field markup into two different functions.

    Finally, for each text input field you want to test, call the appropriate testing function.

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

Sidebar

Related Questions

I am currently working on rails3 application that uses jQuery. I have a javascript
I'm currently working on a JavaScript tool that, during the course of its execution,
I am currently working on a project and my goal is to locate text
Here's what I have so far but thing aren't really working. (I dragged the
I'm currently working on a very poor developed system, and I have to make
I've created a Greasemonkey script which replaces a page function: (function() { var oldFunc
I have a column saved as LONGTEXT on mysql. This text saves rich text.
In my javascript method I have this: if (getInternetExplorerVersion() != '-1') { alert(IE!); Ice.Menu.showIt(targCompObject.offsetLeft
I currently working on an issue tracker for my company to help them keep
I'm currently working on creating a new C# project that needs to interact with

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.