JS implementation Form form submission before the confirmation prompt

Source: Internet
Author: User

Window.confirm usage

The Confirm () method displays a dialog box with the specified message and OK and Cancel buttons.

Example

The code is as follows Copy Code

<a href= "" Javascript:if ("Confirm that you want to delete this content?") location= "del.asp?&areyou= Delete &id=1" "> Delete </a>

To define a function, the advantage is that it can be called repeatedly:

The code is as follows Copy Code


<script language= "JavaScript" >
function Del_sure () {
var gnl=confirm ("OK to delete?");
if (gnl==true) {
return true;
}else{
return false;
}
}
</script>

With all this talk, we're going to get down.

The code is as follows Copy Code


 
  <title>validator</title>
  <script type= text/ JavaScript
   function Checkform () {
    if window.confirm ("Are you sure you want t o sumbit this form? ") {
     return true;
   }
    return false;
  }
  </SCRIPT>
 
 <body>
  <form action= "2.html" onsubmit= "Return checkform [)"
   please click the submit button:<br>
   <input Type= "Text" name= "text" value= "text" ><br>
   <input type= "Submit"
  </form
 </body>

The

Core is this sentence if (window.confirm ("Are you sure your want to sumbit this form?"), it returns True when we click Yes and then commits, otherwise it cancels the operation.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.