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,027

HOME > PHP > PHP Forum > ฟังก์ชั่น check input code เป็นแบบนี้นะคะ code เป็นแบบนี้นะคะ .. กรุณากรอก username ไม่เกิน 20 ตัวอักษรแล้วค่ะ



 

ฟังก์ชั่น check input code เป็นแบบนี้นะคะ code เป็นแบบนี้นะคะ .. กรุณากรอก username ไม่เกิน 20 ตัวอักษรแล้วค่ะ

 



Topic : 030660



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



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




code เป็นแบบนี้นะคะ

Code (JavaScript)
<script>
function checkstu(){
	if(document.forms.stu.std_name.value =="")
	{
		alert("กรุณากรอกชื่อด้วย");		//alert with appropriate message
		document.forms.stu.std_name.select();	//place cursor on the input box
		return false;
	}
		
	if(document.forms.stu.std_email.value =="")
	{
		alert("กรุณากรอกอีเมล์ด้วยน่ะค่ะ");		//alert with appropriate message
		document.forms.stu.std_email.select();	//place cursor on the input box
		return false;
	}

	a=document.stu.std_email.value;
	var l=a.length-1;
	var s=a.indexOf("@"); 
	var d=a.lastIndexOf(".");
	var s2=a.lastIndexOf("@");
	if(a.charAt(0)=="@"|| 
	a.charAt(l)=="@"||d-s<3||
	a.charAt(0)=="."||a.charAt(l)=="."||
	a.length<8||s!=s2||a.indexOf("@")==-1||
	a.indexOf(" ")!=-1||a.indexOf("*")!=-1||
	a.indexOf("/")!=-1||a.indexOf("&")!=-1||
	a.indexOf("<")!=-1||a.indexOf(">")!=-1||
	a.indexOf("?")!=-1||a.indexOf("|")!=-1||
	a.indexOf(":")!=-1||a.indexOf(",")!=-1||
	a.indexOf("=")!=-1||a.indexOf(")")!=-1||
	a.indexOf("(")!=-1||a.indexOf("%")!=-1||
	a.indexOf("#")!=-1)
	{
	alert("อีเมล์ไม่ถูกต้องน่ะค่ะ");
	document.stu.std_email.focus();
	return false;
	}
	if(document.forms.stu.std_user.value == "")
	{
		alert("กรุณากรอก username ด้วย");		//alert with appropriate message
		document.forms.stu.std_user.select();	//place cursor on the input box
		return false;
	}
	if(document.forms.stu.std_user.value.length<5){
		alert("กรอก username อย่างน้อย 5 ตัวอักษร");		//alert with appropriate message(document.forms.stu.username.value.length>20)
		document.forms.stu.std_user.select();	//place cursor on the input box
		return false;
	}
	if(document.forms.stu.std_user.value.length>20){
		alert("กรุณากรอก username ไม่เกิน 20 ตัวอักษรแล้วค่ะ");		//alert with appropriate message(document.forms.stu.username.value.length>20)
		document.forms.stu.std_user.select();	//place cursor on the input box
		return false;
	}	
	
	if(document.forms.stu.std_password.value =="")
	{
		alert("กรุณากรอก password ด้วยน่ะค่ะ");		//alert with appropriate message
		document.forms.stu.std_password.select();	//place cursor on the input box
		return false;
	}	
	if(document.forms.stu.std_password.value.length<5){
		alert("กรอก password อย่างน้อย 5 ตัวอักษร");		//alert with appropriate message(document.forms.stu.username.value.length>20)
		document.forms.stu.std_password.select();	//place cursor on the input box
		return false;
	}
	if(document.forms.stu.std_password.value.length>20){
		alert("กรุณากรอก password ไม่เกิน 20 ตัวอักษรแล้วค่ะ");		//alert with appropriate message(document.forms.stu.username.value.length>20)
		document.forms.stu.std_password.select();	//place cursor on the input box
		return false;
	}
	}
</script>




แล้วพอเวลา ไปกรอกข้อความที่ form เนี่ย มันไม่เช็คให้หน่ะค่ะ
form เป็นแบบนี้

Code (HTML)
<?php
<form action="registerdo.php" method="post" enctype="multipart/form-data" name="stu" onSubmit="return checkstu();">
        <table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
          <tr>
            <td colspan="2"><h4 align="center" class="style2 style5"><font color="#0033CC">กรุณากรอกแบบฟอร์มข้างล่างนี้ให้ครบทุกช่องและกดปุ่ม ลงทะเบียน<br>ผู้เรียนจะต้องกรอกทุกช่องที่มีเครื่องหมาย</font> <font color="#0033CC"><span class="style9">*</span> </font></h4></td>
          </tr>
          
          <tr>
            <td width="30%"><div align="right" class="style5"><font color="#FF0000">*</font> <font face="MS Sans Serif">ชื่อ นามสกุล </font></div></td>
            <td width="70%"><input name="std_name" type="text" class="style5" id="std_name" size="30"/></td>
          </tr>
          <tr>
            <td height="24"><div align="right"><span class="style5"><font color="#FF0000">*</font> <font face="MS Sans Serif">อีเมล์</font></span><font face="MS Sans Serif"><span class="style3"></span></font></div></td>
            <td><input name="std_email" type="text" class="style5" id="std_email" size="30"/></td>
          </tr>
          
          <tr>
            <td height="31" colspan="2"><div align="center">
              <h4>&nbsp;</h4>
              <h4><span class="style3 style5 style6"><font color="#0000FF"><b><font color="#0033CC">ชื่อใช้สำหรับเข้าสู่ระบบผู้เรียน (กรอก Username และ Password)</font></b></font></span><font color="#5C7E32"><b>
                <label></label>
                </b>
                  <label></label> 
                
              </font></h4>
            </div>
              <b><font color="#0000FF">
              <label></label>
            </font></b><label></label></td>
          </tr>
          <tr>
            <td><div align="right" class="style5"><font color="#FF0000" face="MS Sans Serif">* </font> <font face="MS Sans Serif">Username</font></div></td>
            <td><input name="std_user" type="text" class="style5" id="std_user" size="30"/></td>
          </tr>
          <tr>
            <td><div align="right" class="style5"><font color="#FF0000" face="MS Sans Serif">* </font> <font face="MS Sans Serif">Password</font></div></td>
            <td><input name="std_password" type="password" class="style5" id="std_password" size="30"/></td>
          </tr>
          <tr>
          
          <tr>
            <td>&nbsp;</td>
            <td><label>
              <input type="submit" name="Submit" value="ลงทะเบียน" />
               <input type="reset" name="Submit" value="ยกเลิก" />
            </label></td>
          </tr>
          <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
      </form>
?>


ช่วยหน่อยค่ะ



Tag : - - - -







Move To Hilight (Stock) 
Send To Friend.Bookmark.
Date : 2009-08-23 11:04:25 By : ying-oohho View : 1555 Reply : 4
 

 

No. 1



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



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


สงสัย ไม่มีใครช่วยแน่เลย






Date : 2009-08-23 12:32:37 By : ying-oohho
 


 

No. 2



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

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

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

ลองดูแล้วนะครับใช้ได้ครับ ปรกติ
Date : 2009-08-29 15:24:19 By : Dragons_first
 

 

No. 3



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

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

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

Code (JavaScript)
<script>
function checkstu(){
if(document.forms.stu.std_name.value =="")
{
alert("กรุณากรอกชื่อด้วย"); //alert with appropriate message
document.forms.stu.std_name.select(); //place cursor on the input box
return false;
}

if(document.forms.stu.std_email.value =="")
{
alert("กรุณากรอกอีเมล์ด้วยน่ะค่ะ"); //alert with appropriate message
document.forms.stu.std_email.select(); //place cursor on the input box
return false;
}

a=document.stu.std_email.value;
var l=a.length-1;
var s=a.indexOf("@"); 
var d=a.lastIndexOf(".");
var s2=a.lastIndexOf("@");
if(a.charAt(0)=="@"|| 
a.charAt(l)=="@"||d-s<3||
a.charAt(0)=="."||a.charAt(l)=="."||
a.length<8||s!=s2||a.indexOf("@")==-1||
a.indexOf(" ")!=-1||a.indexOf("*")!=-1||
a.indexOf("/")!=-1||a.indexOf("&")!=-1||
a.indexOf("<")!=-1||a.indexOf(">")!=-1||
a.indexOf("?")!=-1||a.indexOf("|")!=-1||
a.indexOf(":")!=-1||a.indexOf(",")!=-1||
a.indexOf("=")!=-1||a.indexOf(")")!=-1||
a.indexOf("(")!=-1||a.indexOf("%")!=-1||
a.indexOf("#")!=-1)
{
alert("อีเมล์ไม่ถูกต้องน่ะค่ะ");
document.stu.std_email.focus();
return false;
}
if(document.forms.stu.std_user.value == "")
{
alert("กรุณากรอก username ด้วย"); //alert with appropriate message
document.forms.stu.std_user.select(); //place cursor on the input box
return false;
}
if(document.forms.stu.std_user.value.length<5){
alert("กรอก username อย่างน้อย 5 ตัวอักษร"); //alert with appropriate message(document.forms.stu.username.value.length>20)
document.forms.stu.std_user.select(); //place cursor on the input box
return false;
}
if(document.forms.stu.std_user.value.length>20){
alert("กรุณากรอก username ไม่เกิน 20 ตัวอักษรแล้วค่ะ"); //alert with appropriate message(document.forms.stu.username.value.length>20)
document.forms.stu.std_user.select(); //place cursor on the input box
return false;
} 

if(document.forms.stu.std_password.value =="")
{
alert("กรุณากรอก password ด้วยน่ะค่ะ"); //alert with appropriate message
document.forms.stu.std_password.select(); //place cursor on the input box
return false;
} 
if(document.forms.stu.std_password.value.length<5){
alert("กรอก password อย่างน้อย 5 ตัวอักษร"); //alert with appropriate message(document.forms.stu.username.value.length>20)
document.forms.stu.std_password.select(); //place cursor on the input box
return false;
}
if(document.forms.stu.std_password.value.length>20){
alert("กรุณากรอก password ไม่เกิน 20 ตัวอักษรแล้วค่ะ"); //alert with appropriate message(document.forms.stu.username.value.length>20)
document.forms.stu.std_password.select(); //place cursor on the input box
return false;
}
}
</script>
<form action="registerdo.php" method="post" enctype="multipart/form-data" name="stu" onSubmit="return checkstu();">
<table width="90%" border="0" align="center" cellpadding="5" cellspacing="0">
<tr>
<td colspan="2"><h4 align="center" class="style2 style5"><font color="#0033CC">กรุณากรอกแบบฟอร์มข้างล่างนี้ให้ครบทุกช่องและกดปุ่ม ลงทะเบียน<br>ผู้เรียนจะต้องกรอกทุกช่องที่มีเครื่องหมาย</font> <font color="#0033CC"><span class="style9">*</span> </font></h4></td>
</tr>
<tr>
<td width="30%"><div align="right" class="style5"><font color="#FF0000">*</font> <font face="MS Sans Serif">ชื่อ นามสกุล </font></div></td>
<td width="70%"><input name="std_name" type="text" class="style5" id="std_name" size="30"/></td>
</tr>
<tr>
<td height="24"><div align="right"><span class="style5"><font color="#FF0000">*</font> <font face="MS Sans Serif">อีเมล์</font></span><font face="MS Sans Serif"><span class="style3"></span></font></div></td>
<td><input name="std_email" type="text" class="style5" id="std_email" size="30"/></td>
</tr>
<tr>
<td height="31" colspan="2"><div align="center">
<h4>&nbsp;</h4>
<h4><span class="style3 style5 style6"><font color="#0000FF"><b><font color="#0033CC">ชื่อใช้สำหรับเข้าสู่ระบบผู้เรียน (กรอก Username และ Password)</font></b></font></span><font color="#5C7E32"><b>
<label></label>
</b>
<label></label> 
</font></h4>
</div>
<b><font color="#0000FF">
<label></label>
</font></b><label></label></td>
</tr>
<tr>
<td><div align="right" class="style5"><font color="#FF0000" face="MS Sans Serif">* </font> <font face="MS Sans Serif">Username</font></div></td>
<td><input name="std_user" type="text" class="style5" id="std_user" size="30"/></td>
</tr>
<tr>
<td><div align="right" class="style5"><font color="#FF0000" face="MS Sans Serif">* </font> <font face="MS Sans Serif">Password</font></div></td>
<td><input name="std_password" type="password" class="style5" id="std_password" size="30"/></td>
</tr>
<tr>
<tr>
<td>&nbsp;</td>
<td><label>
<input type="submit" name="Submit" value="ลงทะเบียน" />
<input type="reset" name="Submit" value="ยกเลิก" />
</label></td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
</table>
</form>
?>

Date : 2009-08-29 15:26:53 By : Dragons_first
 


 

No. 4



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

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

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

ลืมบอกไปว่าให้ไว้ใน ฟอร์มเดียวกันเลยครับ
Date : 2009-09-09 11:17:19 By : Dragons_first
 

   

ค้นหาข้อมูล


   
 

แสดงความคิดเห็น
Re : ฟังก์ชั่น check input code เป็นแบบนี้นะคะ code เป็นแบบนี้นะคะ .. กรุณากรอก username ไม่เกิน 20 ตัวอักษรแล้วค่ะ
 
 
รายละเอียด
 
ตัวหนา ตัวเอียง ตัวขีดเส้นใต้ ตัวมีขีดกลาง| ตัวเรืองแสง ตัวมีเงา ตัวอักษรวิ่ง| จัดย่อหน้าอิสระ จัดย่อหน้าชิดซ้าย จัดย่อหน้ากึ่งกลาง จัดย่อหน้าชิดขวา| เส้นขวาง| ขนาดตัวอักษร แบบตัวอักษร
ใส่แฟลช ใส่รูป ใส่ไฮเปอร์ลิ้งค์ ใส่อีเมล์ ใส่ลิ้งค์ 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 (หรือล็อกอินเข้าระบบสมาชิกเพื่อไม่ต้องกรอก)







Exchange: นำเข้าสินค้าจากจีน, Taobao, เฟอร์นิเจอร์, ของพรีเมี่ยม, ร่ม, ปากกา, power bank, แฟลชไดร์ฟ, กระบอกน้ำ

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