Closed Thread Icon

Topic awaiting preservation: Help on validating the confirm() function in Javascript (Page 1 of 1) Pages that link to <a href="https://ozoneasylum.com/backlink?for=22905" title="Pages that link to Topic awaiting preservation: Help on validating the confirm() function in Javascript (Page 1 of 1)" rel="nofollow" >Topic awaiting preservation: Help on validating the confirm() function in Javascript <span class="small">(Page 1 of 1)</span>\

 
Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 08-12-2004 10:11

I am trying to validate the confirm() funtion to return true in OK button is clicked in to return false if CANCEL button is clicked. i do not know how to refer to the OK or CANCEL button... Here

code:
function comfirmDel(userForm){
confirm("Are you sure you want to Delete this Object?\nNote: This operation is not reversible.\nSelect Cancel if you do not want to Perform this Operation.");
userForm.btnDelete.focus();
}


.................... I intend to call the confirmDel(...) method in a form Below

<FORM name=update action='servlet/dmsDelUser' method=post onsubmit="return comfirmDel(this)">

..... no matter what button i chose when the confirm dialog prompts, my forms still submit..
i'll Apreciate any help Thanks.

(Edited by Fikzy on 08-12-2004 10:13)

Slime
Lunatic (VI) Mad Scientist

From: Massachusetts, USA
Insane since: Mar 2000

posted posted 08-12-2004 10:20

The confirm() function itself returns true or false based on which button the user clicks (OK -> true, Cancel -> false).

Simply

return confirm(...);


 

Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 08-12-2004 10:34

i tried doing some thing like....

code:
<FORM name=update action='servlet/dmsDelUser' method=post onsubmit="Javascript:confirm('Are you sure you want to Delete this Object?\nNote: This operation is not reversible.\nSelect Cancel if you do not want to Perform this Operation.')">



..... But No mater what button i click, it still submits the Form!

Help Thanks..

BillyRayPreachersSon
Nervous Wreck (II) Inmate

From: London
Insane since: Jul 2004

posted posted 08-12-2004 13:33

Change yor onsubmit to this:

code:
onsubmit="return(confirm('Are you sure you want to Delete this Object?\nNote: This operation is not reversible.\nSelect Cancel if you do not want to Perform this Operation.'));">



Hope this helps,
Dan

Fikzy
Nervous Wreck (II) Inmate

From:
Insane since: Aug 2004

posted posted 08-14-2004 14:01

Thanks man. It works..

« BackwardsOnwards »

Show Forum Drop Down Menu