Register Register Member Login Member Login Member Login Forgot Password ??
PHP , ASP , ASP.NET, VB.NET, C#, Java , jQuery , Android , iOS , Windows Phone
 

Registered : 109,038

HOME > PHP > PHP Forum > จากกรณีโค้ดด้านล่างครับ ถ้าผมต้องการจะบังคับให้กรอกทุกช่องนี่ต้องทำไงอ่ะครับ


[PHP] จากกรณีโค้ดด้านล่างครับ ถ้าผมต้องการจะบังคับให้กรอกทุกช่องนี่ต้องทำไงอ่ะครับ

 
Topic : 126612



โพสกระทู้ ( 51 )
บทความ ( 0 )



สถานะออฟไลน์



จากกรณีโค้ดด้านล่างครับ ถ้าผมต้องการจะบังคับให้กรอกทุกช่องนี่ต้องทำไงอ่ะครับ
Code (PHP)
01.<head>
02.<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
03.<title>Untitled Document</title>
04.<script language="javascript">
05.function CheckIPAddress(objInput){
06.var reString = '^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$';
07.var txt = document.getElementById(objInput);
08. 
09.var re = new RegExp(reString);
10.if(!txt.value.match(re)){
11.alert('รูปแบบของ ip address ไม่ถูกต้อง');
12.}else{
13.alert('รูปแบบของ ip address ถูกต้อง');
14.form2.submit();
15.}
16.}
17.</script>
18.</head>
19.<body>
20.<form id="form2" name="form2" method="post" action="add.php">
21.  <table width="500" border="0" align="center">
22.    
23.    <tr>
24.      <td width="184" height="38">Reguester name</td>
25.      <td width="14" align="center">:</td>
26.      <td width="319"><label for="re_name"></label>
27.      <input type="text" name="re_name" id="re_name" /></td>
28.    </tr>
29. <tr>
30.<td height="38">IP Address</td>
31.      <td align="center">:</td>
32.      <td><label for="textfield"></label>
33.      <label for="ip"></label>
34.      <input type="text" name="ip" id="ip" />
35. 
36.    </tr>
37.    <tr>
38.      <td height="40">Computer name</td>
39.      <td align="center">:</td>
40.      <td><label for="com_name"></label>
41.        <input type="text" name="com_name" id="com_name" /></td>
42.    </tr>
43.    <tr>
44.      <td height="39">Mac address</td>
45.      <td align="center">:</td>
46.      <td><label for="mac"></label>
47.        <input type="text" name="mac" id="mac" /></td>
48.    </tr>
49.    <tr>
50.      <td height="35">From</td>
51.      <td align="center">:</td>
52.      <td><label for="textfield5"></label>
53.        <input type="text" name="start" id="start" /></td>
54.    </tr>
55.    <tr>
56.      <td height="40">To</td>
57.      <td align="center">:</td>
58.      <td><label for="textfield6"></label>
59.        <input type="text" name="finished" id="finished" /></td>       
60.    </tr>
61.    <tr>
62.      <td>Remark</td>
63.      <td align="center">:</td>
64.      <td><label for="remark"></label>
65.        <label for="remark"></label>
66.        <textarea name="remark" id="remark" cols="45" rows="5"></textarea></td>
67.    </tr>
68.  </table>
69.<input type="button" name="button" id="button" value="บันทึก" onclick="CheckIPAddress('ip')" />
70.</form>
71.</body>




Tag : PHP, Ms SQL Server 2012, JavaScript

Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2017-02-28 10:25:13 By : puruther View : 658 Reply : 3
 

 

No. 1



โพสกระทู้ ( 110 )
บทความ ( 0 )



สถานะออฟไลน์


ลองดูเป็นแนวทางครับ
Code (PHP)
01.<html>
02.<script type="text/javascript">
03.function fncSubmit()
04.{
05.    if(document.getElementById('checkbox').checked  == false  )
06.    {
07.        alert('PLEASE CHECK IN BOX');
08.        return false;
09.    }
10.    if(document.getElementById('textfield').value  == ""  )
11.    {
12.        alert('PLEASE INPUT YOURTEXT');
13.        return false;
14.    }
15.}
16.</script>
17.<body >
18.<form  action="" method="post" enctype="multipart/form-data" onSubmit="JavaScript:return fncSubmit();">
19.  <input type="checkbox" name="checkbox" id="checkbox">xxxx
20.  <input type="text" name="textfield" id="textfield">
21.  <input type="submit" name="button" id="button" value="Submit">
22.</form>
23.</body>
24.</html>

แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-28 11:02:37 By : JJAAYY
 

 

No. 2



โพสกระทู้ ( 51 )
บทความ ( 0 )



สถานะออฟไลน์


ขอบคุณมากครับ ^^
แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-28 11:54:10 By : puruther
 

 

No. 3



โพสกระทู้ ( 74,059 )
บทความ ( 838 )

สมาชิกที่ใส่เสื้อไทยครีเอท

สถานะออฟไลน์
Twitter Facebook


แสดงความคิดเห็นโดยอ้างถึง ความคิดเห็นนี้
Date : 2017-02-28 21:13:15 By : mr.win
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : จากกรณีโค้ดด้านล่างครับ ถ้าผมต้องการจะบังคับให้กรอกทุกช่องนี่ต้องทำไงอ่ะครับ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ FTP| ใส่แถวของตาราง ใส่คอลัมน์ตาราง| ตัวยก ตัวห้อย ตัวพิมพ์ดีด| ใส่โค้ด ใส่การอ้างถึงคำพูด| ใส่ลีสต์
smiley for :lol: smiley for :ken: smiley for :D smiley for :) smiley for ;) smiley for :eek: smiley for :geek: smiley for :roll: smiley for :erm: smiley for :cool: smiley for :blank: smiley for :idea: smiley for :ehh: smiley for :aargh: smiley for :evil:
Insert PHP Code
Insert ASP Code
Insert VB.NET Code Insert C#.NET Code Insert JavaScript Code Insert C#.NET Code
Insert Java Code
Insert Android Code
Insert Objective-C Code
Insert XML Code
Insert SQL Code
Insert Code
เพื่อความเรียบร้อยของข้อความ ควรจัดรูปแบบให้พอดีกับขนาดของหน้าจอ เพื่อง่ายต่อการอ่านและสบายตา และตรวจสอบภาษาไทยให้ถูกต้อง

อัพโหลดแทรกรูปภาพ

Notice

เพื่อความปลอดภัยของเว็บบอร์ด ไม่อนุญาติให้แทรก แท็ก [img]....[/img] โดยการอัพโหลดไฟล์รูปจากที่อื่น เช่นเว็บไซต์ ฟรีอัพโหลดต่าง ๆ
อัพโหลดแทรกรูปภาพ ให้ใช้บริการอัพโหลดไฟล์ของไทยครีเอท และตัดรูปภาพให้พอดีกับสกรีน เพื่อความโหลดเร็วและไฟล์ไม่ถูกลบทิ้ง

   
  เพื่อความปลอดภัยและการตรวจสอบ กระทู้ที่แทรกไฟล์อัพโหลดไฟล์จากที่อื่น อาจจะถูกลบทิ้ง
 
โดย
อีเมล์
บวกค่าให้ถูก
<= ตัวเลขฮินดูอารบิก เช่น 123 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)





ThaiCreate.Com Logo
© www.ThaiCreate.Com. 2003-2025 All Rights Reserved.
ไทยครีเอทบริการ จัดทำดูแลแก้ไข Web Application ทุกรูปแบบ (PHP, .Net Application, VB.Net, C#)
[Conditions Privacy Statement] ติดต่อโฆษณา 081-987-6107 อัตราราคา คลิกที่นี่