|
 |
|
สอบถามตรวจสอบข้อมูลjavaขณะกรอก ถ้าพิมพ์ผิดจะไม่แสดงตัวอักษร ถ้าความยาวของอักษรน้อย หรือ มากไป ให้ขึ้นข้อความข้างๆ textbox จะต้องทำยังไง |
|
 |
|
|
 |
 |
|
ลองทำแล้วไม่เกิดอะไรขึ้นเลยค่ะ
|
|
|
v
ไฟล์(frmlogin.php)
[font=Verdana]<script type="text/javascript" src="veriflogin.js"></script>[/font]
<form name="form1" id="form1">
<table width="450" border="0" align="center">
<tr>
<td colspan="2"><strong>Member Register</strong></td>
</tr>
<tr>
<td>Username :</td>
<td><input name="txtUsername" type="text" id="txtUsername" size="12"
onKeyUp="verifLogin(this.value)"> <span id="msg1"></span><br /><span id="msg2"></span> </td> //สีเขียวเพื่อแสดงเครื่องหมายถูกผิด หลังผ่านการตรวจสอบ //สีชอพูเพื่อแสดงข้อความหลังผ่านการตรวจสอบ
</tr>
<tr>
<td>Password :</td>
<td><input name="txtPassword" type="text" id="txtPassword" size="12"></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="Login"></td>
</tr>
</table>
</form>
______________________________
ไฟล์ veriflogin.js
function writediv(texte) {
document.getElementById('msg2').innerHTML = texte;
}
function verifLogin(txt) {
if ( txt != '' ) {
if ( txt.length < 6 ) {
writediv('<span style="color:#cc0000">อย่างน้อย 6 ตัวอักษร !</span>');
} elseif ( txt.length > 10 ) {
writediv('<span style="color:#cc0000">ไม่เกิน 20 ตัวอักษร !</span>');
} elseif ( getFile('veriflogin.php?username=' + escape(txt)) ) {
document.getElementById('msg1').innerHTML = xhr_object.responseText;
}
}
}
function getFile(url) {
if ( window.XMLHttpRequest ) {
xhr_object = new XMLHttpRequest();
} else if ( window.ActiveXObject ) {
xhr_object = new ActiveXObject( "Microsoft.XMLHTTP" );
} else {
return(false);
}
xhr_object.open( "GET" , url, false );
xhr_object.send(null);
if (xhr_object.readyState == 4) {
return(xhr_object.responseText);
} else {
return(false);
}
}
----------------------------------------------------------------
ไฟล์ veriflogin.php
<?php
require("config.php");
$strTxt = $_GET['username'];
$result = mysql_query("SELECT member_username FROM tbl_member WHERE member_username = '$strTxt' ");
if (trim($strTxt) == "" ) {
echo "<img src='image/icon_wrong.gif'>";
exit();
} else {
if (mysql_num_rows($result) >= 1 ) {
echo "<img src=\"image/icon_wrong.gif\" width=\"20\" height=\"20\" />";
} else {
echo "<img src=\"image/icon_correct.gif\" width=\"20\" height=\"20\" />";
}
}
?>
หน้านี้ขึ้นอย่างนี้ค่ะ "; exit(); } else { if (mysql_num_rows($result) >= 1 ) { echo ""; } else { echo ""; } } ?>
จากหนังสือ จีระสิทธิ์ อึ้งรัตนวงศ์
|
 |
 |
 |
 |
Date :
2012-05-22 14:59:17 |
By :
ging0o0 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่เข้าใจค่า
|
 |
 |
 |
 |
Date :
2012-05-22 15:11:49 |
By :
ging0o0 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ลองอ่านทุกความคิดเห็นน่ะครับ จะพบกับข้อมูลตัวอย่าง ก็ลองสร้างตารางตามที่ให้ไว้ด้วย
|
 |
 |
 |
 |
Date :
2012-05-22 15:24:52 |
By :
sakuraei |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|