<!doctype html> <html> <head> <meta charset="utf-8"> <title>cookie</title> </head> <script src="https://cdn.bootcss.com/jquery/2.1.1/jquery.min.js"></script> <script src="jquery-cookie/jquery.cookie.js"></script> <body> <input onkeyup="value=value.replace(/[W]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))" ID="Text1" NAME="Text1"> <input onkeyup="value=value.replace(/[^d]/g,'') " onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^d]/g,''))" ID="Text2" NAME="Text2"> <input type="text" id="intye" value=""> </body> <script> $(function () { if($("#intye").val()==""){ $("#intye").val($.cookie("ms")); }else{ $.cookie("ms", $("#intye").val(), {path: "/", expires: 30}); } $("#intye").keyup(function(){ if($("#intye").val()==""){ }else{ $.cookie("ms", $("#intye").val(), {path: "/", expires: 30}); } }) }) </script> </html>