채택완료

알러트 동작 문제

Copy
<form name="wp" id="wp" method="post" action="./pointupdate.php" autocomplete="off">
    <ul class="point_all">
        <li class="full_li">
            보유포인트
            <span><?php echo number_format($member['mb_point']); ?></span>
        </li>
        <li class="full_li">
        <div>
            <label for="w_point">신청 포인트</label>
            <div style="float:right;">
                <input type="text" name="w_point" id="w_point" size="15" placeholder="0"> 점
            </div>
        </div>
        </li>
    </ul>
    <input type="submit" name="act_button" value="신청" onclick="forderform_check(this.form);" class="btn_close" style="background:#ebebeb;">
</form>

<script>
function wp(f) {
    if (f.w_point.value)
    {
        temp_point = parseInt(f.w_point.value);
        if (temp_point < 0) {
            alert("포인트를 0 이상 입력하세요.");
            f.w_point.select();
            return false;
        }
        if (temp_point > <?php echo (int)$member['mb_point']; ?>) {
            alert("회원님의 포인트보다 많이 신청할 수 없습니다.");
            f.w_point.select();
            return false;
        }
    }
}
</script>

 

이렇게 코드를 짰는데요 알러트 부분이 정상동작하지 않아요

 

뭐가 문제일까요?

답변 1개 / 댓글 3개

채택된 답변
+20 포인트

form 어디에도 함수 wp를 실행시키는게 없네요

해당 함수wp에 든 내용을 forderform_check에 넣어야 할것같네요

답변에 대한 댓글 3개

form에 onsubmit="return wp_submit(this);"

버튼에 onclick="document.pressed=this.value"

이렇게 넣어도 안되는데 혹시 어떻게 해야 하는건가요?
함수 명이 wp이니 wp을 넣어줘야합니다
form에 onsubmit="return wp(this);"

답변을 작성하려면 로그인이 필요합니다.