Reputation: 591
I am designing a web-form to save some data. I am relatively new in this field .
Can someone give some exmamples of how to implement validations on form controls using javascript before a postback occurs.
Meaning, if the validations return true ( indicating some field missing ) then we don't do the postback and vice-versa.
Thanks,
Mangesh
Upvotes: 1
Views: 827
Reputation: 118
Ya you can use form with onSubmit function. as shown below
<form onsubmit="return Validate()">
... your controls will go here with submit button...
</form>
<script type="text/javascript">
function Validate() {
do your validations here all goes well return true else return false
}
</script>
Hope this answered your question
Upvotes: 2