Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

"Are you sure?" Page

Status
Not open for further replies.

david7777777777

Programmer
Sep 26, 2001
417
US
I've got a form ASP page talking to a SQL 2000 database and I'd like to allow the user to "double-check" his work before the final submit happens. How can I provide the user with a way to "go back" to the form while preserving their data that they entered, or display it in some sort of "final check" screen before the final submit happens so they can verify the information is correct? Thanks.
 
You could use a message box to display a message something like this...

sub DisplayMsg()
dim sMsg , iReturn
sMsg = "Is the information Correct?" & vbCRLF
sMsg = "Field1 : " & document.form(0).Field1.value
.
.
.
iReturn = messagebox sMsg , vbYesNo
if iReturn = 6 then
document.form(0).submit()
end if
end sub


 
Best way to do it and not have the user lose all the data is to use client side scripting like the example above.

Simply run some basic VBScript or JavaScript forms validation against the fields to make sure they have valid info in them (or at least info that is formated correctly), and then before set like a onSubmit function to the form. So that prior to submitting it checks the form and makes sure they want to submit. Then if they check no it returns a false value and the form isn't submitted, allowing them to change whatever they need to change.
 
How about giving me a simple example of some client-side JavaScript form validation please? This is for my ASP application talking to a SQL 2000 database. IE 5.5 is the known browser.

Let's say this is my form, which contains nothing more than a field for your first name and a submit button:

Filename: form1.asp
Form name: form1
Textbox name: txtFirstName
Submit button name: btnSubmit

Thanks!
 
ok.
the onclick event of your submit button should be like so
<input type=button name=btnSubmit onClick='ValidateFields'>

Then before the </html> add below.

<script language=vbscript>

Sub ValidateFields()
if document.form1.txtFirstName.value = &quot;&quot; then
msgBox &quot;Field empty ...&quot;
else
displaymessage()
end if
end sub

sub DisplayMsg()
dim sMsg , iReturn
sMsg = &quot;Is the information Correct?&quot; & vbCRLF
sMsg = &quot;Field1 : &quot; & document.form1.txtFirstName.value
iReturn = messagebox sMsg , vbYesNo
if iReturn = 6 then
document.form1.submit()
end if
end sub

 
Hi,

Client-Side Validation example (Note: Trim function contained within 'Javascript_functions.js' file.)

<script type='text/javascript' src='Javascript_functions.js'></script>

<SCRIPT ID=clientEventHandlersJS LANGUAGE=javascript>
<!--
/////////////////////////////////////////////////////////////
// This function is used to validate data on the
// client before it is submitted to the server to ensure
// columns that do not allow nulls do not get submitted to server
//////////////////////////////////////////////////////////////
function thisPage_onbeforeserverevent( obj, event ){
if (obj==&quot;btsave&quot;)
{
if(event==&quot;onclick&quot;)
// Note: There is no javascript Trim function...
// See Javascript_functions.js included above

{ // Check if something entered for Site Name
if(Trim(document.thisForm.txtsitename.value) == &quot;&quot;)
{
alert(&quot;Site Name cannot be blank!&quot;);
// Cancel the update.
thisPage.cancelEvent = true;
document.thisForm.txtsitename.focus();
}

if(document.thisForm.lbcompanyid.value == &quot;&quot;)
{
alert(&quot;Company cannot be blank!&quot;);
// Cancel the update.
thisPage.cancelEvent = true;
document.thisForm.lbcompanyid.focus();
}

// Check if something entered for Region
if(Trim(document.thisForm.txtregion.value) == &quot;&quot;)
{
alert(&quot;Region cannot be blank!&quot;);
// Cancel the update.
thisPage.cancelEvent = true;
document.thisForm.txtregion.focus();
}

// Check if something entered for Area
if(Trim(document.thisForm.txtarea.value) == &quot;&quot;)
{
alert(&quot;Area cannot be blank!&quot;);
// Cancel the update.
thisPage.cancelEvent = true;
document.thisForm.txtarea.focus();
}

// Check if something entered for UTC Offset
if(Trim(document.thisForm.txtutcoffsetmin.value) == &quot;&quot;)
{
alert(&quot;UTC offset cannot be blank!&quot;);
// Cancel the update.
thisPage.cancelEvent = true;
document.thisForm.txtutcoffsetmin.focus();
}



}

}

}
//-->;

-----------------------------
Note: Trim functions within 'Javascript_functions.js' supplied by // Trim, LTrim, Rtrim JavaScript Functions Written by:
// Scott Mitchell
// mitchell@4guysfromrolla.com
// ------------------------------------------------

Computergeek
 
This looks cool. Where's the 'Javascript_functions.js' file or am I missing something?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top