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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:27:44+00:00 2026-05-20T11:27:44+00:00

Basically, what I am trying to do is alert the same message if one

  • 0

Basically, what I am trying to do is alert the same message if one of the seven text boxes in my form is empty. I have been playing around with it a lot, but now I am starting to feel exasperated; help! Sometimes I get a function validepiste() is not defined error and sometimes I don’t get an error, but there is an alert even if all the boxes have something in them. I think the error might be due to an incorrect use of the || (or) operator, or the length bit. Here is the function (which is within the head tags):

<script type="text/javascript">
function validatepiste()
{
// all form fields must be filled in
var a= document.piste.nom.length;
var b= document.piste.email.length;
var c= document.piste.numtel.length;
var d= document.piste.adresse.length;
var e= document.piste.ville.length;
var f= document.piste.length;
var g= document.piste.travaux.length;
if (a||b||c||d||e||f||g==0){
  alert("Vous devez remplir toutes les cases.");
  return false;
  }
return true
} 
</script>

And the call to that function which is in the html:

<input type="submit" name="Submit" value="Envoyer" onClick="return validatepiste()"/>

Thank you!

  • 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-20T11:27:45+00:00Added an answer on May 20, 2026 at 11:27 am

    There are two issues with your code that I can see.

    First Problem

    It appears you’re trying to access a length property directly on a form element (which doesn’t exist). What you really want to do is access the length of a form value. So instead of this:

    var a= document.piste.nom.length;
    

    Do this:

    var a= document.piste.nom.value.length;
    

    I didn’t see this at first but @Napster mentioned it in his answer. So thank him.

    Second Problem

    You’re if statement has some bad logic. Try the following instead.

    if (a==0||b==0||c==0||d==0||e==0||f==0||g==0) { ... }
    

    Your original expression was asking the following…

    If a is truthy,
    or b is truthy,
    or c is truthy,
    or d is truthy,
    or e is truthy,
    or f is truthy,
    or g is equal to 0
    then show the alert.

    The only scenario which would not have triggered the alert using your existing code would be if all the fields were blank except for g.

    You can read an article about what truthy means if you like.

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

Sidebar

Related Questions

Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I'm basically just trying to submit a form through AJAX and want to show
I have the following snippets of code. Basically what I'm trying to do is
I'm basically trying to figure out the simplest way to perform your basic insert
I'm basically trying to teach myself how to code and I want to follow
I recently came across this in some code - basically someone trying to create
Basically I am trying to restart a service from a php web page. Here
Basically I'm trying to change the Canvas.Left property of an Ellipse Silverlight control in
Basically I am trying to retrieve a list of stored procedure parameters using Linq
I'm trying to basically do a search through the database with Perl to tell

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.