Jump to content

[SOLVED] RegExp function stopping display @ character from javascript cookie variable?!?!


rachwilbraham

Recommended Posts

Hello!

 

We are using a cookie (written in javascript and url encoded and decoded) to store form variables so that when the page is reloaded we can keep the form variables. We are having a problem with the email address field - the cookie only returns the email address up to the @ symbol and we have narrowed it down to the regexp function.... ???

 

 

if (func == 'read') 
      {
        if (thisCookie != '') 
        {
            
              var myregexp = new RegExp(nameQuery + '([\\w]*)');
              var match = myregexp.exec(thisCookie);
              if (match != null && match.length > 1 && match[1] != '') 
            {
                return match[1];
              }
        }
    return null;
      }
}

 

 

Can anyone help?!

 

Thanks in advance!

 

I have no idea why you would want to save form field values to cookies. If you have a form I would expect that you are using some type of server-side code (such as PHP) to process the form. It is much more efficient to repopulate the form on the server-side (using POST variables) than in JavaScript.

 

But you can allow the at symbol by simply adding it to the regex expression

var myregexp = new RegExp(nameQuery + '([\\w@]*)');

OMG we can't believe its actually that simple!!! You wouldn't believe it but me n the boss have been trying to figure that out all day!!!! (we're in england....its nearly going home time!)

 

Thank you so so so so so so much!!!! Our saviour!!! Lol!  :D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.