[英]winjs: textbox content validation and alerts using popup message dialog box?
我有文本框和按鈕的形式。 我有454個html文件,然后從該文本框中收集數字並顯示相應輸入的數字的html文件。 這是問題所在。 如果用戶輸入1到454之間的數字,則打開相應的文件。 否則,什么也沒發生。 但是,我有一個消息對話框代碼。
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代碼:
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.");
}
}
您實際上並沒有提出問題,但是Windows.UI.Popups.MessageDialog()僅創建彈出消息。 為了顯示它,您需要像這樣調用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.