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!

 

Link to comment
Share on other sites

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@]*)');

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.