2014-09-01 226 views
-1

我喜歡添加確認對話框。如「確認添加(金額)?」如果是的話,它會繼續addcontribution.php,如果沒有,它會回到自己並重置該字段。在JS確認對話框

<form form="CONTRIFORM" name='contribution' method="POST" Action="addcontribution.php" onSubmit="return formvalidation2();"> 
    <center> 
    Amount: 
    <input type="text" name="contriamnt" id="contriamnt" size="15" placeholder=" Amount"></br></br> 
    <button id="searchbutton" type="submit" name="submit" value="Submit">ADD</button></br> 
    </center> 
</form> 

<script> 

function formvalidation2() { 
    var amntDATA = document.contribution.contriamnt; 
    if(allnumber(amntDATA)) { 
     if(ChangeText()) { 
      if(new_tab()) { 
      } 
     } 
    } 
    return false; 
} 

function allnumber(amntDATA) { 
    var x = /^[0-9]+$/; 
    if(amntDATA.value.match(x)) { 
     return true; 
    } else { 
     alert('Invalid Amount.'); 
     return false; 
    } 
} 
</script> 
+0

確認功能將幫助您 – V31 2014-09-01 13:29:14

回答

1

if (confirm('Confirm Adding (the amount)?')){ 
    window.location = "http://www.google.com/"; // your Custom Link 
}else{ 
    document.getElementById('contriamnt').value=""; 
}