Results 1 to 2 of 2

Thread: โค๊ดform validate java มีปัญหา ครับ

  1. #1
    Member
    Join Date
    May 2009
    Location
    thai
    Posts
    45


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-874" />
    <title>สมัครสมาชิก</title>
    <script language="Javascript"><!--

    function validatefrm(){ var theForm = document.frmAdd;

    var errMsg = "";

    var setfocus = "";

    if (theForm[&#39;name&#39;].value == ""){

    errMsg = "ชื่อ - นามสกุล";

    setfocus = "[&#39;name&#39;]";

    }

    if (theForm[&#39;email&#39;].value == ""){

    errMsg = "อีเมล์";

    setfocus = "[&#39;email&#39;]";

    }

    if (theForm[&#39;username&#39;].value == ""){

    errMsg = "ชื่อเข้าระบบ";

    setfocus = "[&#39;username&#39;]";

    }

    if (theForm[&#39;password&#39;].value == ""){

    errMsg = "รหัสผ่าน";

    setfocus = "[&#39;password&#39;]";

    }

    if (theForm[&#39;confirm_password&#39;].value == ""){

    errMsg = "อืนยันรหัสผ่าน";

    setfocus = "[&#39;password&#39;]";

    }

    if (errMsg != ""){

    alert(errMsg);

    eval("theForm" + setfocus + ".focus()");

    }

    else theForm.submit();

    }

    </script>

    </head>

    <body>
    <h2 align="center">สมัครสมาชิก</h2>
    <form action="" method="post" name="frmAdd" id="frmAdd" onSubmit="validatefrm();return false;">
    <table align="center">
    <tr><td>ชื่อ - นามสกุล</td><td><input type="text" name="name"></td></tr>
    <tr><td>อีเมล์</td><td><input type="text" name="email"></td></tr>
    <tr><td>ชื่อเข้าระบบ</td><td><input type="text" name="username"></td></tr>
    <tr><td>รหัสผ่าน</td><td><input type="password" name="password"></td></tr>
    <tr><td>ยืนยันรหัสผ่าน</td><td><input type="password" name="confirm_pass"></td></tr>
    <tr><td colspan="2" align="center"><input type="submit" value="submit"><input type="reset" value="ลบใหม่ทั้งหมด"></td></tr>
    </table>
    </form>
    <h4 align="center">* กรุณากรอกข้อมูลให้ครบ</h4>
    </body>
    </html>
    คือผมสงสัยว่าทําไมเวลาเรากรอกข้อมูลไม่ครบทําไมมันเชคvalidate จะแก้ไขยังไงส่วนไหนครับ ไม่เข้าใจ

  2. #2
    Senior Member retool2's Avatar
    Join Date
    Aug 2008
    Location
    Under Relocation
    Posts
    178


    แก้ตามนี้ดูครับ
    [hide=3][code]
    <script language="Javascript"><!--
    function validatefrm(){

Similar Threads

  1. Replies: 0
    Last Post: 19-03-2010, 04:21 PM
  2. javascript validate array checkbox
    By retool2 in forum PHP,ASP,Javascript, Html
    Replies: 0
    Last Post: 24-09-2008, 01:00 PM
  3. Replies: 1
    Last Post: 01-03-2008, 10:54 AM
  4. Replies: 3
    Last Post: 08-11-2007, 01:47 PM
  5. Validate Window (Fix)
    By keepack in forum Window Application
    Replies: 0
    Last Post: 14-07-2007, 03:05 AM

Members who have read this thread : 0

Actions : (View-Readers)

There are no names to display.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •