admin管理员组文章数量:1293740
Is there a way to have a confirm dialog box display the value a user typed in a text box on a form? (For example, if the user types 100.00, I'd like the dialog box display a message something like, "Confirm Amount. Click OK if $100.00 is the correct amount.")
Is there a way to have a confirm dialog box display the value a user typed in a text box on a form? (For example, if the user types 100.00, I'd like the dialog box display a message something like, "Confirm Amount. Click OK if $100.00 is the correct amount.")
Share asked Jul 27, 2010 at 16:17 SpockratesSpockrates 751 gold badge5 silver badges14 bronze badges3 Answers
Reset to default 5Yes:
var amount = document.getElementById("textbox").value;
confirm("Confirm Amount. Click OK if $" + amount + " is the correct amount.")
EDIT: Here is a working example: http://jsbin./inoru/edit
Sure, you can just pass a string value to the dialog:
var str = "my msg";
confirm(str);
So to display your custom message, just get the value of the text box and append it to your message. For example:
var amount = jQuery("#myTextBox").val();
confirm("Click OK if " + amount + " is the correct amount");
You should check the onblur event from the textbox, if the textbox is not empty then show the message, sth like this:
document.getElementById('textboxid').onblur = function(){
if(this.value.length > 0 )
showApplicationMessage()
}
本文标签: JavaScript Confirm dialog box that shows value from a text boxStack Overflow
版权声明:本文标题:JavaScript: Confirm dialog box that shows value from a text box - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741587119a2386909.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论