-> Javascript form validataion (display alert one by one)
-> the following code is used when your page(like new user register form) under master page
->and you not use a master page that time you only changes following
->document.getElementById('ctl00_ContentPlaceHolder1_txtFName').value;
->in above line remove the "ctl00_ContentPlaceHolder1_ " word in all line
->and not required the copy following two line
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
-> Your .aspx page
------------------------------------------------------------------------------------------------
-> the following code is used when your page(like new user register form) under master page
->and you not use a master page that time you only changes following
->document.getElementById('ctl00_ContentPlaceHolder1_txtFName').value;
->in above line remove the "ctl00_ContentPlaceHolder1_ " word in all line
->and not required the copy following two line
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
-> Your .aspx page
------------------------------------------------------------------------------------------------
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<script type="text/javascript" language="javascript">
function validate() {
var FName = document.getElementById('ctl00_ContentPlaceHolder1_txtFName').value;
var LName = document.getElementById('ctl00_ContentPlaceHolder1_txtLName').value;
var CompanyName = document.getElementById('ctl00_ContentPlaceHolder1_txtCompName').value;
var CompanySite = document.getElementById('ctl00_ContentPlaceHolder1_txtCompSite').value;
var NoUser = document.getElementById('ctl00_ContentPlaceHolder1_txtNoUser').value;
var Email = document.getElementById('ctl00_ContentPlaceHolder1_txtEmail').value;
var Phone = document.getElementById('ctl00_ContentPlaceHolder1_txtPhone').value;
var AccountName = document.getElementById('ctl00_ContentPlaceHolder1_txtAccountName').value;
var Account_Id = document.getElementById('ctl00_ContentPlaceHolder1_txtAccountId').value;
var Password = document.getElementById('ctl00_ContentPlaceHolder1_txtAccountPass').value;
var ConfirmPass = document.getElementById('ctl00_ContentPlaceHolder1_txtConfirm').value;
if (FName == "")
{
alert(" First Name Required");
return false;
}
else if
(!isNaN(FName)) {
alert(" Digit Not Allowed");
return false;
}
else if
(!isNaN(LName)) {
alert(" Digit Not Allowed");
return false;
}
else if (CompanyName
== "") {
alert("Company Name Required");
return false;
}
else if (NoUser == "") {
alert("No Of User Required");
return false;
}
else if
(isNaN(NoUser)) {
alert(" Character Not Allowed in No.
User");
return false;
}
else if (Email == "") {
alert(" Email ID Required");
return false;
}
else if (Phone == "") {
alert("Phone Or Mobile Required");
return false;
}
else if
(isNaN(Phone)) {
alert(" Character Not Allowed");
return false;
}
else if (Phone.length
< 10 || Phone.length > 12) {
alert("Enter valid Phone No.");
return false;
}
else if (AccountName
== "") {
alert(" Account Name Required");
return false;
}
else if (Account_Id
== "") {
alert(" User Name Required");
return false;
}
else if (Password == "") {
alert("
Enter Your Password");
return false;
}
else if
(Password.length < 7 || Password.length > 12) {
alert(" Password Minimum 6 Character
");
return false;
}
else if (ConfirmPass
== "") {
alert(" Enter Confirm Password");
return false;
}
else if (ConfirmPass
!= Password) {
alert(" Confirm Password not match");
return false;
}
else {
return true;
}
}
</script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<h2><asp:Label ID="Label1" Text="New User" runat="server" /></h2>
<asp:Label ID="lblAccNMMsg" runat="server" ForeColor="Red"></asp:Label>
<asp:Label ID="Label12" runat="server"
Font-Bold="True"
Text="Personal
Information"></asp:Label>
<asp:Label ID="Label2" runat="server"
Text="First
Name"></asp:Label>
<asp:TextBox ID="txtFName" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label3" runat="server"
Text="Last
Name"></asp:Label>
<asp:TextBox ID="txtLName" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label5" runat="server" Text="Company Name"></asp:Label>
<asp:TextBox ID="txtCompName" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label6" runat="server" Text="Company Website"></asp:Label>
<asp:TextBox ID="txtCompSite" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label7" runat="server" Text="No. of User"></asp:Label>
<asp:TextBox ID="txtNoUser" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label13" runat="server"
Font-Bold="True"
Text="Contact
Information"></asp:Label>
<asp:Label ID="Label4" runat="server"
Text="E-Mail
ID"></asp:Label>
<asp:TextBox ID="txtEmail" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label125" runat="server" Text="Phone No."></asp:Label>
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label14" runat="server"
Font-Bold="True"
Text="Account
Information"></asp:Label>
<asp:Label ID="Label8" runat="server" Text="Account Name"></asp:Label>
<asp:TextBox ID="txtAccountName" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label9" runat="server" Text="User Name"></asp:Label>
<asp:TextBox ID="txtAccountId" runat="server"></asp:TextBox><br/>
<asp:Label ID="Label10" runat="server" Text="Password"></asp:Label>
<asp:TextBox ID="txtAccountPass" runat="server" TextMode="Password"><br/>
</asp:TextBox>
<asp:Label ID="Label11" runat="server" Text="Confirm Password"></asp:Label>
<asp:TextBox ID="txtConfirm"
runat="server"
TextMode="Password"></asp:TextBox><br/><br/>
<asp:Button ID="btnSignUp"
runat="server"
Text="Sign
Up" OnClientClick="return validate();"
onclick="btnSignUp_Click" />
<asp:Button ID="btnCancel"
runat="server"
Text="Cancel"
/>
</asp:Content>
No comments:
Post a Comment