• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

error_validation

 
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hello everyone..
can anybody pls guide me as to what is wrong in the following valdation code.
<script language="javascript"<
<!--
isSubmit=true;
function nullcheck(s)
{
return(s==" ");
}
function validate()
{
isSubmit=true;
flag=1;
if(flag==1)
{
if(document.f1.login.value==" ")
{
alert("login cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.pass1.value==" ")
{
alert("password cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.pass2.value==" ")
{
alert("confirm password cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.pass1.value!=document.f1.pass2.value)
{
alert("both the password should be the same");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.fname.value==" ")
{
alert("first name cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.lname.value==" ")
{
alert("last name cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.address.value)
{
alert("address cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.city.value=="")
{
alert("city cannot be left blank");
isSubmit=false;
flag=0;
}
}
if(flag==1)
{
if(document.f1.state.value=="")
{
alert("state cannot be left blank");
isSubmit=false;
flag=0;
}
}
//for null check and not a string(pin number)
if(flag==1)
{
if(document.f1.pincode.value==" "||isNaN(document.f1.pincode.value))
{
alert("pin number cannot be left blank or it cannot be a string");
isSubmit=false;
flag=0;
}
}
//for null check and not a string(phone number)
if(flag==1)
{
if(document.f1.phone.value==" "||isNaN(document.f1.phone.value))
{
alert("phone number cannot be left blank or it cannot be a string");
isSubmit=false;
flag=0;
}
}
//for email valdation
if(flag==1)
{
smail=document.f1.email.value;
semail=smail.replace(".","!");
len=semail.length;
se=semail.search("@");
setmail=semail.substr(parseInt(se)+1,parseInt(len)-parseInt(se));
se1=setmail.search("!");
setdomain=setmail.substr(parseInt(se1)+1,parseInt(len)-parseInt(se1));
len1=setdomain.length;
f1=1;
if(!nullcheck(semail)||!nullcheck(setmail))
{
for(i=0;i<=len;i++)
{
if(semail.substr(i,1)== " ")
f1=1;
}
}

if(parseint(se)<=0||parseInt(se1)<=0||parseInt(len1)<1||f1==1)
{
alert("invalid email id");
isSubmit=false;
flag=0;
}
else
{
if(nullcheck(semail.substr(parseInt(se1)-1,1))||nullcheck(semail.substr(parseInt(se1)+1,1)))
{
alert("invalid email id");
isSubmit=false;
flag=0;
}
}
}
else
{
alert("invalid email id");
isSubmit=false;
flag=0;
}
}
--<
<script<
i have put validation when user submits the button .

and enjoy ur day!!
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what is the error you are getting?
(You may want to look at the link below)
Eric
 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
what is the error you are getting?
(You may want to look at the link below)
Eric

 
jyotsana dang
Ranch Hand
Posts: 135
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Eric Pascarello:
what is the error you are getting?
(You may want to look at the link below)
Eric[/QUOTE
thanks for the link..
the validation part is working now..
but still not able to figure out how to validate an email

 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
if you are using my code: validate="Email" is what you need....
if you are using your own code....
this is what I use to check the email
 
reply
    Bookmark Topic Watch Topic
  • New Topic