DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

+ Reply to Thread
Results 1 to 2 of 2
  1. #1
    JB Cox Guest

    How to not submit when checking a form


    <html>
    <head>
    <title>formtest.htm</title>
    <script language="javascript">
    <!--
    function submitform(){
    if(document.thisform.txtname.value.length==0) {
    alert("Please enter your name.");
    return false;
    }else{
    return true;
    }
    }
    //-->
    </script>
    </head>
    <body>
    <form name="thisform" method="post" action="formtest.htm" onSubmit="return
    submitform();">
    Enter your name: <input type="text" name="txtname" value="" size=20 maxlength=20><br>
    <input type="submit" value="Submit">
    </form>
    </body>
    </html>


  2. #2
    Chandra Guest

    Re: How to not submit when checking a form

    Form action should call any server side script/program like cgi,pl,dll,asp,
    servlet .. etc. Note the changes in your code

    JB Cox <jbcox@maxit-inc.com> wrote in message
    news:3978bd48$1@news.devx.com...
    >
    > <html>
    > <head>
    > <title>formtest.htm</title>
    > <script language="javascript">
    > <!--
    > function submitform(){
    > if(document.thisform.txtname.value.length==0) {
    > alert("Please enter your name.");
    > return false;
    > }else{
    > return true;
    > }
    > }
    >-->

    </script>
    > </head>
    > <body>
    >


    <form name="thisform" method="post"
    action="should be any server side script or program like cgi,pl,dll,asp
    ...etc"
    onSubmit="return submitform();">

    > Enter your name: <input type="text" name="txtname" value="" size=20

    maxlength=20><br>
    > <input type="submit" value="Submit">
    > </form>
    > </body>
    > </html>
    >




Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


Top DevX Stories

Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL


Sponsored Links