<script type="text/javascript" language="javascript">
function PreSaveAction()
{
if(condiction)
return true
else
return false
}
</script>
If the function PreSaveAction return false, then the item form will not be submitted and keep on the creating or updating form.if the function PreSaveAction return true, then the item will be submitted.We usually use put the code under this node of New form and update form aspx files :
<asp:Content ContentPlaceHolderId="PlaceHolderTitleAreaClass" runat="server">
link to : http://blog.csdn.net/abrahamcheng/article/details/8004569