7 Replies - 1752 Views - Last Post: 15 May 2012 - 07:19 PM

#1 so0oma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 01-January 11

validation code

Posted 04 May 2012 - 10:31 AM

Hi,
i use the below code for validation
it was work , but when i add mobile validation it is not wok
can you help me to make the mobile validation done?

function validation(form)
{
var Numeric = "^[0-9]+$";
var x=document.forms["myForm"]["email"].value;
var atpos=x.indexOf("@");
var dotpos=x.lastIndexOf(".");
var txtMobileNumber = document.getElementById("mobile").value;


if (atpos<1 || dotpos<atpos+2 || dotpos+2>=x.length)
  {
  alert("Not a valid e-mail address");
  return false;

 }

if ((form.Fname.value)=="")
{
alert("enter the First emplyee name !!")
return false;
}

if ((form.salary.value)=="")
{
alert("enter the employ's salary !!")
return false;
}

if(form.txtMobileNumber.value == "")
{
alert('Please Enter Required fields\n\n* Indicates Required fields')
return false;
}
if(form.txtMobileNumber.length < 12)
{
alert('Mobile Number must be 12 digits\n\n Enter with country code 91');
return false;
}

if(form.txtMobileNumber.search(Numeric) == -1)
{
alert('Mobile Number must be Numeric');
return false;
document.getElementById("mobile").focus();
}

}


//--></script>


Is This A Good Question/Topic? 0
  • +

Replies To: validation code

#2 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 386
  • View blog
  • Posts: 2,657
  • Joined: 12-January 10

Re: validation code

Posted 04 May 2012 - 10:34 AM

error?
Was This Post Helpful? 0
  • +
  • -

#3 so0oma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 01-January 11

Re: validation code

Posted 04 May 2012 - 10:36 AM

what is the error ?
Was This Post Helpful? 0
  • +
  • -

#4 DarenR  Icon User is offline

  • D.I.C Lover

Reputation: 386
  • View blog
  • Posts: 2,657
  • Joined: 12-January 10

Re: validation code

Posted 04 May 2012 - 10:44 AM

View Postso0oma, on 04 May 2012 - 01:36 PM, said:

what is the error ?



I was asking you what error you get when you run the program?
Was This Post Helpful? 0
  • +
  • -

#5 so0oma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 01-January 11

Re: validation code

Posted 04 May 2012 - 10:56 AM

not error , but if i didn't wright any number in mobile filed
the error message don't appear....
Was This Post Helpful? 0
  • +
  • -

#6 Dormilich  Icon User is offline

  • 痛覚残留
  • member icon

Reputation: 3393
  • View blog
  • Posts: 9,591
  • Joined: 08-June 10

Re: validation code

Posted 04 May 2012 - 11:20 AM

he meant the error in the Error Console.
Was This Post Helpful? 0
  • +
  • -

#7 so0oma  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 93
  • Joined: 01-January 11

Re: validation code

Posted 04 May 2012 - 11:26 AM

for example >>
if i write the mobile number but is not the same pattern
the information will submit without going to javasecript to check if the enter correct or not
Was This Post Helpful? 0
  • +
  • -

#8 JulianNeill  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 13
  • Joined: 15-May 12

Re: validation code

Posted 15 May 2012 - 07:19 PM

Does mobile even support javascript?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1