工作我試圖顯示警告,如果輸入的是無效的,但OnClientClick這個不工作,這是我的代碼:的OnClientClick不是在JavaScript
function validation1() {
if (document.getElementById('firstname').value == "" || document.getElementById('firstname').value == "First Name..."){
alert("Please Enter First Name");
}
if(document.getElementById('lastname').value == "" || document.getElementById('lastname').value == "Last Name..."){
alert("Please Enter Last Name");
}
}
<asp:Button runat="server" ID="SearchButton" Text="Instant Search" OnClick="SearchButton_Click" OnClientClick="validation1" />
我的代碼是在母版頁,所以這會是一個問題?
已經嘗試了許多不同的方式使用的OnClientClick調用的函數,但沒有成功:
- stackoverflow.com/questions/2155048/onclientclick-and-onclick-is-not-working-at-the-same-time
- OnClick not working when i use both Onclick & OnClientClick
- OnClientClick not working
嘗試'的OnClientClick = 「validation1()」' – TechDo
已嘗試,試圖分號... – Wasi