need some help regarding verifyform

Javascript coding ..

Moderators: egami, macek, gesf

Post Reply
whitemoss
New php-forum User
New php-forum User
Posts: 55
Joined: Thu Apr 14, 2005 1:28 am
Location: Malaysia
Contact:

Wed Aug 24, 2005 8:25 pm

Hi All,

I dunno how to alter the code below:

Code: Select all

<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
function verifyForm()
{
   var themessage = "You are required to complete the following fields: ";
   var valid = "191111111" // numbers only
   var ok = "yes";
   var temp;
   
   if (document.form1.MobileNumber.value=="")
   {
      themessage = themessage + " - Enter Mobile Number";

      alert(themessage);
      document.form1.MobileNumber.focus();
      return false;
   }

   for (var i=0; i < document.form1.MobileNumber.value.length; i++)
   {
      temp = "" + document.form1.MobileNumber.value.substring(i, i+1);
      if (valid.indexOf(temp) == "-1") ok = "no";
   }

   if (ok == "no")
   {
      alert("Invalid entry!  Only numbers are accepted!");
      document.form1.MobileNumber.focus();
      document.form1.MobileNumber.select();
      return false;
   }

   return true;
}
//  End -->

</script>


actually that code will reflect if user didnt enter any value for mobile number and also enter non digit of mobile number..but when user enter mobile number which consist of 0, pop up window "Invalid entry! Only numbers are accepted!" appeared. 0 is still a number..so how to alter that code...

thanks in advance

Post Reply
  • Information
  • Who is online

    Users browsing this forum: No registered users and 1 guest