but here choses one them to demo.
1. prepare JavaScript function
<script language="javascript"> function checkForm() { if(document.formaddNews.m_name.value=="") { alert("PLZ enter name!"); document.formaddNews.m_name.focus(); return false; } if(document.formaddNews.m_content.value=="") { alert("PLZ enter product content!"); document.formaddNews.m_content.focus(); return false; } if(document.formaddNews.m_type.value=="") { alert("PLZ enter product type!"); document.formaddNews.m_type.focus(); return false; } return confirm('R U sure?'); }
2.HTML
<form action="" enctype="multipart/form-data" method="POST" name="formaddNews" id="formaddNews" onSubmit="return checkForm();"> <input type="submit" name="Submit2" value="add">
沒有留言:
張貼留言