In .NET we do validations to restrict wrong entries and making valid values to be entered through the forms.
Validation on a form or UI page can be done on two sides
1 Server Side Validation
2 Client Side Validation
Server Side validation we provide when we want to check the details after making request to the server
For providing server side validation we will use ASP validators
Ex : <asp:TextBox id="txtName"
runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator1" runat="server"
ErrorMessage="Required!"
ControlToValidate="txtName">
</asp:RequiredFieldValidator>
Client side validation we provide when we wan to check the details as they are entered instantly into the form
For providing client side validation we use Javascript validators or Jquery validators
Ex : <script>
function checkname()
{
var name=document.getElementByID("txtName").value;
if(name=="")
{
alert("Name cannot be left blank");
}
}
</script>
0 Comment(s)