Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to restrict form submit

 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,

i have delete link in the page,when its clicked it ask's for confirmation.when i click on cancel button,then the page is submitted and the value is deleted.how to restrict form submit when clicked on cancel button

here is code in the jsp page
----------------------------------
<script type="text/JavaScript">
function callDelete(){

if((confirm("Do you really want to delete this complaint ?")==false)){
return false;
}
</script>

}
<html:form method="post" action="/complaintAction">
.
.
.
<html:link action="/complaintAction?methodType=deleteComplaints" paramId="complaintId" paramName="CComplaint" paramProperty="complaintId" onKlick="callDelete()">Delete </html:link></div></td>

</html:form>
-------------------------

help me out...

Thanks
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi sreenivas,

there's an error in your Javascript.

</script>
}

should be

}
</script>

Herman
PS thanks to Firefox + webdeveloper plugin.
 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Herman,

now i changed the code to this, the same problem is repeated.i am unable to restrict the form submit

<script type="text/JavaScript">
function callDelete(){

if((confirm("Do you really want to delete this complaint ?")==false)){
return false;
}

}
</script>
 
Herman Schelti
Ranch Hand
Posts: 387
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
add return to your event-handler:



Herman
 
sreenivas jeenor
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Herman,

its working now.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic