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 Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

confirm form 1

Status
Not open for further replies.

glenmac

Technical User
Joined
Jul 3, 2002
Messages
947
Location
CA
I'm trying to give the user a chance to cancel a form submission.
Code:
<script language="JavaScript">
function chkForm() {
    if (confirm("Are you sure you want to send form?")) {
            submit();
        }
else return(false);
    }

</script>
...    
<FORM action = "test.htm" onsubmit = "chkForm(this)" >
    <input id="ID00" type="text" value="00"> <br />
    <input type="submit"  />

</FORM>
Must be too early and I'm a little fuzzy anyhow this doesn't work. Can anyone help? All help is much appreciated.

Glen
 
glenmac;

Code:
<script language="JavaScript">
function chkForm() {
    return confirm("Are you sure you want to send form?");
}

</script>
...    
<FORM action = "test.htm" onsubmit = "return chkForm();" >
    <input id="ID00" type="text" value="00"> <br />
    <input type="submit" />
</FORM>

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
hey...

just want to bring up a point... don't use this as the be-all and end-all... if this is protecting sensitive information from being changed, you might want to implement a check on the server-side (like maybe displaying another page asking the user to confirm).

for example, if there's a link to delete a record, and the user has javascript disabled, then he/she won't get the javascript confirmation message.

just something to think about.

*cLFlaVA
----------------------------
[tt]a frickin' twelve-gauge, what do you think?[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top