简体   繁体   中英

Display null cookie value as empty space using jquery or javascript

I have stored some textbox values in cookies.

But if the textbox is blank then the cookie value will be "null".

I am assigning that cookie value to another textbox. But as the cookie value is null it shows "null" in textbox.

I want to replace this "null" with a blank space.

How can I do that?

First thing to do would be to modify the code that stores the cookie value so that it doesn't write null for blank textboxes. If that is not feasible, then just use javascript:

string.replace('null','')

Note that this will prevent you from having the exact literal "null" in your fields so the first alternative is preferred.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM