使用django atm:
这是我的表格:
<form name="chrisForm" action="">
<input type="text" name="christext">
<br>
<button type='submit' class='btn btn-primary btn-xs' onclick="return chrisFunction()">
Submit</button>
</form>
<!-- modify the searchwords form -->
<form name="articleForm" action="" method="post">{% csrf_token %}
<input type="text" placeholder='Modify the keywords' name="searchkeyword">
<br><button type="submit" class="btn btn-success btn-xs" onclick="return validateForm()">Submit</button>
</form>
下面是来自外部源的javascript函数:
function validateForm() {
var x = document.forms['articleForm']['searchkeyword'].value;
if (x == null || x == "") {
alert("Please enter a search keyword(s)");
return false
}
}
function chrisFunction() {
var y = (document.forms['chrisForm']['christext'].value);
if (y === "1" || y === "2") {
alert('You have entered 1 or 2, congrats!');
return false
}
else if
(y === "" || y === null) {
window.open('http://forbiddengrounds.net',"", height="200", width="200");
}
}
当我点击我的按钮时,它除了处理“action”部分之外什么都不做,但是当我点击按钮时,它应该会发出警报,而不会在文本框中输入任何内容(或者为chrisFunction输入1或2)
目前没有回答
相关问题 更多 >
编程相关推荐