Hello Friends,
As you know everybody need require field validation for their inquiry form or any other kind of forms. Because many people do not provide right information regarding their email id contact number etc. So today i am going to tell you how you can setup require field validation in your website form.
I am going to provide many way how you can setup require field validation by using asp.net, java script etc.
Screenshot
Add following Java Script code in your webpage Head section
Screenshot
As you know everybody need require field validation for their inquiry form or any other kind of forms. Because many people do not provide right information regarding their email id contact number etc. So today i am going to tell you how you can setup require field validation in your website form.
I am going to provide many way how you can setup require field validation by using asp.net, java script etc.
Require Field Validation using ASP.Net
If you are using Visual Studio then its become very easy to keep validation because Visual Studio provide you control tag.
Source Code for Require Field Validation Message as popup form
<asp:ValidationSummary ID="ValidationSummary1"
runat="server"
ShowMessageBox="true"
ShowSummary="false"/>
<asp:Label ID="Label1" runat="server" Text="Name*"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:requiredfieldvalidator ID="Requiredfieldvalidator1" runat="server"
errormessage="enter
your name" Display="None" ControlToValidate="TextBox1"></asp:requiredfieldvalidator>
<asp:Button ID="Button1" runat="server" Text="Submit" />
Screenshot
Source Code for Require Field Validation Message as Summery
<asp:ValidationSummary ID="ValidationSummary1"
runat="server"
ShowMessageBox="false"
ShowSummary="true"/>
<asp:Label ID="Label1" runat="server" Text="Name*"></asp:Label>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:requiredfieldvalidator ID="Requiredfieldvalidator1" runat="server"
errormessage="enter
your name" Display="None" ControlToValidate="TextBox1"></asp:requiredfieldvalidator>
<asp:Button ID="Button1" runat="server" Text="Submit" />
Java Script Code for Require Field Validation
<script>
function validateForm() {
var
x = document.forms["validationForm"]["fname"].value;
if
(x == "") {
alert("Please
Enter Your Name");
return
false;
}
}
</script>
Use Following Code where you want to setup Validation
<form name="validationForm"
onsubmit="return
validateForm()" method="post" action="">
Name: <input type="text" name="fname">
<input type="submit"
value="Submit">
If you face any difficulty using these code or not able to setup validation in your contact form please write in comment box i will reply you as soon as possible
This comment has been removed by a blog administrator.
ReplyDelete