Javascript search help
stuart576
Status: New User - Welcome
Joined: 10 Oct 2008
Posts: 1
Reply Quote
i am using javascript to check a form before a user submits it, but the search part isn't working:

:: Code ::
   var str = document.newacc.email.value;
   var searchterm = /@/i;
   var match = str.search(searchterm);

   if(document.newacc.email.value.length < 1){
      document.newacc.email.style.backgroundColor='#121212';
      ok = 0
   } else if (match = -1){
      document.newacc.email.style.backgroundColor='#772222';
      ok = 0
   }else{
      document.newacc.email.style.backgroundColor='#227722';
      ok = 1
   }


obviously i have put this inside a function, and it has other if statements in it, and they all work fine.

Can I not search for an '@' because its a special character or something?
Back to top
Display posts from previous:   

All times are GMT - 8 Hours