Solved

How can I submit a form depend on the input?

Posted on 1998-10-08
6
175 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
Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction This tutorial will give you a fast look what you can do with WhizBase. I expect you already know how to work with HTML at least, and that you understand the basics of the internet and how the internet works. WhizBase is a server-s…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
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…

738 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