[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Verify Form data, then submit

Posted on 2004-09-09
4
Medium Priority
?
1,027 Views
Last Modified: 2008-01-09
When a user enters info into a Form, how would I verify the data and then submit the Form to another page that handles the data?

I need to have the form page open message boxes if the data the entered is incorrect and make the user try again, or if the data is correct, submit the form to another .asp page.

currently I just have this which just sends the form without checking the data:

<form name="form1" method="post" action="SendSuggestion.asp">

Thanks
0
Comment
Question by:mgcIT
[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 Comments
 
LVL 15

Assisted Solution

by:Colosseo
Colosseo earned 200 total points
ID: 12019676
Hi

One of if not the most common way to do this would be to use javascript

in your form you would change your submit button to a button and give it an onclick event like

<input type=button name=submit onclick="verifyAndSubmit()">

Then you would have a javascript function defined on your page to validate the form data

<script language="javascript">

  function verifyAndSubmit() {
    var f = document.form1;
   
    //an example of check
    if(f.txtfield.value==""){alert{'You must enter a value in the textfield');return false;}
   
    // submit the form if all validations pass
    f.submit();
  }
</script>

HTH

let me know if you want help with the validation

Scott
0
 
LVL 2

Assisted Solution

by:LinuxCluster
LinuxCluster earned 200 total points
ID: 12019684
Hi mgcIT,

you have too choices:

1) verify the data the user enters with the help of a JavaScript.
    + It checks the entered data immediately
    + It can pop up an alert box if soemthing is wrong
    - JavaScript needs to be activated
    - You will have to run multiple scripts for different types of fields (phone number, date, name etc.)

2) submit the form to an asp page that does error checking with the fields and if soemthing is not right, it can send the user back to the form page and display the according error messages. If everything is allright it will go to SendSuggestion.asp.
    + No JavaScript neccessary
    + You can write a function and reuse the different entry verifyers
    + You can design the error msg. with the website design
    - One extra step for the server to handle (but is minimal)
    - The user has to submit the form first, and then fix any mistakes

Depending on what solution you prefer we can give you the apropriate solution.

Regards,
LinuxCluster
0
 
LVL 15

Accepted Solution

by:
joeposter649 earned 200 total points
ID: 12019901
Don't use the onclick even as a form can be submitted sometimes by just hitting enter.
Use the onsubmit event of the form and be sure to return the result so it doesn't submit...
onsubmit="return validate()">

Have validate() return true if it's ok to submt and false if there were problems.

http://www.w3schools.com/js/tryit.asp?filename=tryjs_formvalidate
0
 
LVL 18

Author Comment

by:mgcIT
ID: 12020238
many thanks to everyone...
0

Featured Post

Independent Software Vendors: 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

I would like to start this tip/trick by saying Thank You, to all who said that this could not be done, as it forced me to make sure that it could be accomplished. :) To start, I want to make sure everyone understands the importance of utilizing p…
I was asked about the differences between classic ASP and ASP.NET, so let me put them down here, for reference: Let's make the introductions... Classic ASP was launched by Microsoft in 1998 and dynamically generate web pages upon user interact…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…

656 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