Solved

How can I submit a form depend on the input?

Posted on 1998-10-08
6
179 Views
Last Modified: 2013-12-25
There is an input box in my asp, like this" <form name="frmSave1" method="POST" action="/cargo/save.asp">
<p><input type="text" name="T1" size="5"> ...."
if T1 is A~Z ,submit the form,else don't submit it.
How can I do this?Thank you very much!!
0
Comment
Question by:lijin1
[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
  • 4
6 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1828973
<SCRIPT LANGUAGE="JavaScript"><!--

// --------------------------------------------------------------------
// COMPANY:       Netscape Communications
// AUTHOR:        Robert W. Husted
// DATE CREATED:  March 17, 1997
// MODIFIED BY:
// DATE MODIFIED:
// --------------------------------------------------------------------

// CHECK STRING - ENSURE ALL CHARACTERS ARE LETTERS
function toAlpha(checkString)
{
    newString = "";    // REVISED/CORRECTED STRING
    count = 0;         // COUNTER FOR LOOPING THROUGH STRING

    // LOOP THROUGH STRING CHARACTER BY CHARACTER
    for (i = 0; i < checkString.length; i++) {
        ch = checkString.substring(i, i+1);

        // ENSURE CHARACTER IS AN ALPHA CHARACTER
        if ((ch >= "a" && ch <= "z") || (ch >= "A" && ch <= "Z" )) {
            newString += ch;
        }
    }

    if (checkString != newString) {
      // VERIFY WITH USER THAT IT IS OKAY TO REMOVE INVALID CHARACTERS
      if (confirm("The value you have entered\ncontains invalid characters,\nis it okay to remove them?")) {
        // RETURN REVISED STRING
        return newString;
      } else {
        // RETURN ORIGINAL STRING
        return checkString;
      }
    }
    return checkString;
}

/* This is added by me */
function checkSubmit(theForm) {
   Text = theForm.T1.value;
   ChkText = toAlpha(Text);
   if ( Text == ChkText ) return true;
   else {
      theForm.T1.value = ChkText;
      retun false;
   }
}
//--></SCRIPT>
<form name="frmSave1" method="POST" action="/cargo/save.asp" onSubmit="return checkSubmit(this)">
<p><input type="text" name="T1" size="5">
</FORM>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1828974
Oops, typo - retun should be return:

   else {
        theForm.T1.value = ChkText;
        retun false;
   }

should be

  else {
          theForm.T1.value = ChkText;
          return false;
   }
0
 

Author Comment

by:lijin1
ID: 1828975
Thank you very much, mplungjan.
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
LVL 10

Expert Comment

by:MasseyM
ID: 1828976
Why was this rejected?  
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 1828977
Thanks MasseyM, I was wondering the same thing, perhaps the wrong radio was selected?

Michel
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 200 total points
ID: 1828978
I will reanswer this in case Lijin1 just went away, not to come back...

Michel
0

Featured Post

Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

Question has a verified solution.

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

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
This article will show, step by step, how to integrate R code into a R Sweave document
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to dynamically set the form action using jQuery.

729 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