[英]winjs: textbox content validation and alerts using popup message dialog box?
I have the form with textbox and button. 我有文本框和按钮的形式。 I have 454 html files, and from that textbox i gather the number and shown the respective entered number's html files. 我有454个html文件,然后从该文本框中收集数字并显示相应输入的数字的html文件。 Here is the problem. 这是问题所在。 If the user enters in between 1 and 454, respective file is opened. 如果用户输入1到454之间的数字,则打开相应的文件。 Else, nothing happened. 否则,什么也没发生。 but, i have a Message Dialog code for that. 但是,我有一个消息对话框代码。
HTML Code: HTML代码:
<div class="win-content win-settings-section">
<input type="text" id="number" />
<button type="button" id="buttonClick">Show !</button>
<div id="def-content"></div>
</div>
JavaScript Code : JavaScript代码:
function buttonClick()
{
var getFile = document.getElementById("number").value;
if (getFile < 455 && getFile > 0)
{
var output = new WinJS.UI.HtmlControl(document.getElementById("def-content"), { uri: '/def/f' + getFile + '.html' });
}
else
{
Windows.UI.Popups.MessageDialog("Expected Value Range: 1 to 454.");
}
}
You haven't really asked a question, but Windows.UI.Popups.MessageDialog() only creates the popup message. 您实际上并没有提出问题,但是Windows.UI.Popups.MessageDialog()仅创建弹出消息。 In order to show it you need to call the showAsync() method like this. 为了显示它,您需要像这样调用showAsync()方法。
function buttonClick()
{
var getFile = document.getElementById("number").value;
if (getFile < 455 && getFile > 0) {
var output = new WinJS.UI.HtmlControl(document.getElementById("def-content"), { uri: '/def/f' + getFile + '.html' });
} else {
var popup = Windows.UI.Popups.MessageDialog("Expected Value Range: 1 to 454.");
popup.showAsync();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.