Solved

how to write java script validate function

Posted on 2006-06-21
1
171 Views
Last Modified: 2010-05-18
Hi:

Currently I am working on an customer order form. The email address should be entered when the user submits. So I need add something like "input type=submit value=submit onclick="validate()"  " right? My question is how to write the validate() so that the user won't submit?
0
Comment
Question by:ly_uwo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
boonleng earned 200 total points
ID: 16951896
You need to return true or false in the javascript function.

Example:
<script>
function validate() {
    if (no error) {
        return true;
    } else {
        return false;
    }
}
</script>

<form onsubmit="return validate()">

Note: is best perform validation on onSubmit instead of onclick on the button. This is to cater for user press 'Enter' key.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
stateless EJB with glassfish 2 75
I am having a difficulty creating a responsive Page for my website. 10 89
own marker interface 1 60
jdbc error in jsp application 20 91
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question