Nethra Nethra - 6 months ago 14
Javascript Question

jquery or javascript method to add validations to input tags before submitting the page

I have the below snippet of input tags which are not server controls so unable to use required field validators. So i want to use validators using jquery or java script.Can anyone help me with this.

<div id="win">
<table>
<tr>
<td>
<div>
<label id="lblname" for="Name"(required)>Name</label>
</div>
<div id="dname">
<input data-bind="value: data.Name" id="inpName" />
</div>
</td>
<td>
<div>
<label id="lblend" for="End"(required)>End</label>
</div>
<div id="dend">
<input data-bind="value: data.end" />
</div>
</td>

</tr>
</table>
</div>


<script>
$("#win").validate();
</script>


tried using this but didnt work.

Answer

Here is an example for what you are looking

You have to put the things to be validated in a form tag not in a div. Replace the

<div id="win"> with a

<form id="win">
Comments