OnBlur ASP.NET
<script>
function pageload() {
age.value = "123";
}
</script>
<div class="row">
<h2>Index </h2>
<form method="post" name="form" action="~/Home/Index">
<p>
姓名:<input type="text" name="name"/>
</p>
<p>
年齡:<input type="text" name="age" id="age" onblur="pageload();"/>
</p>
<input type="submit" /> /
<input type="button" class="btn" onclick="location.href = '@Url.Action("Index", "Home")'" value="back"/> //@Razor code
</form>
</div>
因為ASP.NET內建的onblur(移開焦點後)
也可以寫成
if(age.value == "")
age.value = "123";
留言
張貼留言