Wrox Home  
Search P2P Archive for: Go

  Return to Index  

javascript thread: if and else statement: Syntax Error ...plz help meeeee......


Message #1 by "Sukhi Samra" <sukhdeepsamra@h...> on Wed, 3 Oct 2001 20:48:31
Hi ,

split the
elseif (form.cboRegion.value == "None") as

else if (form.cboRegion.value == "None").there should be space betweeen the
esle and if.Thanks.

Jaya
----- Original Message -----
From: "Sukhi Samra" <sukhdeepsamra@h...>
To: "javascript" <javascript@p...>
Sent: Wednesday, October 03, 2001 6:27 PM
Subject: [javascript] RE: if and else statement: Syntax Error ...plz h elp
meeeee......


> Hi John
>
> I did found the example to validate teh phone from internet
> (http://www.cs.umbc.edu/~wyvern/ta/validate.txt)
>
> but the problem i am having now is the syntax error. If you take a look at
> the code below, I copied the
> validate function from the site and put it under else if statement, but
> somehow i am getting a syntax error.
>
> Any idea...why????
>
> Thanks in advance.
>
> Sukhi
> ----------------start of Code--------------------
> <script language="Javascript">
> function frmNewMember_Validator(form){
> if (form.Mem_Name.value == "")
> {
> alert("Please Fill in the Member Name field")
> form.Mem_Name.focus()
> return false
> }
> elseif (form.cboRegion.value == "None")
> {
> alert("Please Fill in the Region field")
> form.cboRegion.focus()
> return false
> }
> elseif (form.Mem_Phone.value<>"")
> {
> function validatePhone(Mem_Phone) {
>      phoneOK = true; // phoneOK is GLOBAL
>      var digits = 0;
>      for (var i=0; i < Mem_Phone.value.length; i++) {
>         var theChar = Mem_Phone.value.charAt(i);
>         if ((theChar >= "0") && (theChar <= "9")) {
>            digits++;
>            continue;
>         }
>         if (theChar == " ") continue;
>         if (theChar == "-") continue;
>         if (theChar == "(") continue;
>         if (theChar == ")") continue;
>         phoneOK = false;
>      }
>
>      phoneOK = phoneOK && (digits == 10);
>      if (!phoneOK) {
>         alert("Please enter a phone number in the format (555) 555-5555");
>         Mem_Phone.focus();
>         Mem_Phone.select();
>      }
>
>      return phoneOK;
>   }
>
> }
> }
> -------------end of code-------------------
>
>
> >From: John Owen <JOWEN@f...>
> >Reply-To: "javascript" <javascript@p...>
> >To: "javascript" <javascript@p...>
> >Subject: [javascript] RE: if and else statement: Syntax Error ...plz h
> >elp meeeee......
> >Date: Wed, 3 Oct 2001 16:28:53 -0500
> >
> >You can use regular expressions in your phone number validation to ensure
> >the user enters the phone number as you expect it. If you have
Professional
> >Javascript by WROX, it has examples on how to implement masks using
> >Javascript. If you don't have the book, I can look it up when I have more
> >time and post an example.
> >
> >John Owen
> >Federal TransTel
> >Senior Developer
> >
> >
> >-----Original Message-----
> >From: Sukhi Samra [mailto:sukhdeepsamra@h...]
> >Sent: Wednesday, October 03, 2001 3:45 PM
> >To: javascript
> >Subject: [javascript] RE: if and else statement: Syntax Error ...plz
> >help meeeee......
> >
> >
> >Thankssssssssss John, It workedddddddd :)
> >
> >one other question, I have input box for Phone Number, Is there a way to
> >put
> >
> >a input mask on it by using javascript? such as (222)222-2222, I mean if
> >that box gets a focus, It should show [(  )   -    ]
> >
> >somthing like that? Is there a way to do that in javascript?
> >
> >Thankss,
> >
> >sukhi

  Return to Index