JavaScript
function Validation() {
RequireFieldValidation();
allLetter();
PasswardValidation();
EmailValidation();
MobValidation();
// if (RequireFieldValidation() == true && allLetter() == true && PasswardValidation() == true && EmailValidation() == true && MobValidation() == true) {
// return true;
// }
// else {
// return false;
// alert("error");
// }
}
function RequireFieldValidation() {
for (var i = 1; i <= 8; i++) {
var name = document.getElementById("TextBox" + i).value;
if (name == "" || name == null) {
alert("Please Enter required info in textbox "+i);
return false;
}
}
//return true;
}
function allLetter()
{
//var n = document.testJavascript.TextBox1;
var name = document.getElementById("TextBox1");
var letters = /^[A-Za-z]+$/;
if (!(name.value.match(letters))) {
alert("Please enter only alphabetic character")
return false;
}
else
{
//return false;
}
}
function PasswardValidation() {
var pwd = document.getElementById("TextBox3").value;
var rpwd = document.getElementById("TextBox4").value;
var len = pwd.length;
if (len <= 5 || len >= 11) {
alert("Please Enter Passward 6 to 10 character long");
return false;
}
else if (pwd != rpwd) {
alert("Passward doesnot match");
return false;
}
else {
// return true;
}
}
function EmailValidation() {
//var n = document.testJavascript.TextBox1;
var email = document.getElementById("TextBox5");
var mailFormate = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
if (!(email.value.match(mailFormate)))
{
alert("Please enter correct email-id")
return false;
}
else
{
//return true;
}
}
function MobValidation() {
//var n = document.testJavascript.TextBox1;
var mob = document.getElementById("TextBox6");
if (isNaN(mob.value)) {
alert("Mobile no. contain incorrect character");
return false; mob.focus();//iske liye variable mob me only getelementbyid chahiye na ki uski value.
C#
}
else if(mob.value.length!=10){
alert("Please enter 10 digit mob no.")
mob.focus();
return false;
}
return true; }
<form id="form1" runat="server" onsubmit="Validation()" method="post" name="testJavascript" action="#">
5 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Sunny SharmaRank #223 · 11.1K pointsPosted Apr 29, 2013, 10:50 PM EDT
Arun Kurmi96 pointsPosted Apr 30, 2013, 4:05 AM EDT
1 name
2 user name
3 passward
4 retype passward
5 e-id
6 mob no
with above code my validation work expected and give alert box for every wrong input
until only and only 1 textbox remaing for entering value but when i entered value in last textbox(serial no of textbox doesnot metter it can be any one out total 6 textbox) and this value are wrong then validation do not give an error messege.for ex. when i enter wrong text for mob no in the last textbox and click on button it simply submit the form and never give an error messege.
Sunny SharmaRank #223 · 11.1K pointsPosted Jun 14, 2013, 11:40 PM EDT
Sorry i couldn't respond in time, did you get the solution?
Arun Kurmi96 pointsPosted Jun 14, 2013, 11:58 PM EDT
If you Seen my Stored procedure Question then Please help.
Sunny SharmaRank #223 · 11.1K pointsPosted Jun 15, 2013, 12:29 AM EDT
Thanks.