나는이 tutorial 온라인을 사용하여 양식 필드 중 하나의 입력 값을 저장하려고했습니다.자바 스크립트 쿠키 저장 양식
지금까지 성공하지 못했습니다.
내가 잘못 했나요?
<script type="text/javascript">
var today = new Date();
var expiry = new Date(today.getTime() + 30 * 24 * 3600 * 1000); // plus 30 days
function setCookie(name, value) {
document.cookie=name + "=" + escape(value) + "; path=/; expires=" + expiry.toGMTString();
}
function storeValues(form) {
setCookie("email", form.email-field.value);
return true;
}
if(email = getCookie("email")) document.getElementById('login-form').email-field.value = email-field;
function getCookie(name) {
var re = new RegExp(name + "=([^;]+)");
var value = re.exec(document.cookie);
return (value != null) ? unescape(value[1]) : null;
}
document.write(getCookie("email"));
</script>
HTML :
<form action="" method="post" id="login-form">
<input class="field" type="text" name="email-field" placeholder="e-mail" style="text-transform: lowercase;" autofocus>
<br>
<input class="field" type="password" name="pass" placeholder="password">
<button type="submit"></button>
당신의 절 (이메일 =의 getCookie ("이메일")) 아마해야 할 경우 경우 : 만약 (이메일 ==의 getCookie ("이메일")), 예를 들어 – jyrkim
이것이 효과가 있습니까? – Borsn
아닙니다. 어쨌든, 방금 만든 몇 가지 변경 사항 :-) – jyrkim