|
|
|
อยากทราบวิธีการเช็คภาษาอังกฤษใน textfield อะคับ ลองหลายวิธีแล้วคับผม |
|
|
|
|
|
|
|
คือผมจะให้กรอกได้แต่ภาษาอังกฤษใน textfield อะคับผมลองหาวิธีดูลองถ้าตามก้ไม่ได้อะคับ
Code (PHP)
<?php
session_start();
mysql_query("set names UTF8");
if ($_SESSION['admin'])
{
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv=Content-Type content="text/html; charset=TIS620">
<title>Project</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="buttons/buttons.css" />
<link rel="stylesheet" type="text/css" href="css/jquery.jdigiclock.css" />
<script type="text/javascript" src="lib/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="lib/jquery.jdigiclock.js"></script>
<script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
<script src="SpryAssets/SpryValidationPassword.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
$('#digiclock').jdigiclock();
});
</script>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css" />
<link href="SpryAssets/SpryValidationPassword.css" rel="stylesheet" type="text/css" />
</head>
<script language="javaScript">
function checkemail(str){
var emailFilter=/^.+@.+\..{2,3}$/;
var str=document.form.text1.value;
if (!(emailFilter.test(str))) {
alert ("ท่านใส่อีเมล์ไม่ถูกต้อง");
return false;
}
return true;
}
</script>
<body>
<div id="wrap">
<div id="header">
<div id="topnav">
<ul>
<li class="active"><a href="admin-add.php">add teacher </a></li>
<li><a href="admin-edit.php">edit teacher </a></li>
<li><a href=""></a></li><? //echo "STAT";?>
<li><a href="#"></a></li>
<li><a href="#"></a></li>
<li><a href="logout.php">logout</a></li>
</ul>
</div>
<form name="frmSearch" method="get" action="<?=$_SERVER['SCRIPT_NAME'];?>">
<table width="599" border="0">
<tr>
<th>
<input name="txtKeyword" type="text" id="txtKeyword" value="<?=$_GET["txtKeyword"];?>" class="listBox">
<input type="submit" value="Search">
</th>
</tr>
</table>
</form>
<h1 id="sitename">ADMIN</a></h1>
</div>
<div id="content">
<div id="left">
<div class="post">
<div class="post_h"></div>
<?
include('Connect/connect.php');
@mysql_query("SET NAMES 'TIS620'");
if($_GET["txtKeyword"] != "")
{
// Search
//$strSQL = "SELECT * FROM students, list_stu WHERE students.id_stu = list_stu.id_stu AND students.id_stu LIKE '%".$_GET["txtKeyword"]."%' or students.fname LIKE '%".$_GET["txtKeyword"]."%'";
$strSQL = "SELECT * FROM teacher WHERE (lecturer LIKE '%".$_GET["txtKeyword"]."%' OR fname LIKE '%".$_GET["txtKeyword"]."%')";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
?>
<?
while($objResult = mysql_fetch_array($objQuery))
{
?>
<table>
<tr>
<td width="50"></td>
<td width="100"><div align="center"><?=$objResult["lecturer"];?></div></td>
<td width="45"><?=$objResult["fname"];?></td><td width="90"><?=$objResult["lname"];?></td><td><?=$objResult["email"];?></td>
</tr>
</table>
<?
}
}
else
{
?>
<form action="admin-add-work.php" method="post" id="addteach">
<table width="609" border="0">
<tr>
<td width="92"> </td>
<td width="112"> </td>
<td width="391"> </td>
</tr>
<tr>
<td> </td>
<td>id : </td>
<td>
<span id="sprytextfield1">
<input name="lecturer" type="text" maxlength="5" class="button small blue"/>
<span class="textfieldRequiredMsg"></span><span class="textfieldMinCharsMsg">Minimum 3 characters</span><span class="textfieldMaxCharsMsg">Maximum 5 characters</span></span></td>
</tr>
<tr>
<td> </td>
<td>name : </td>
<td>
<span id="sprytextfield2">
<input name="name" type="text" maxlength="40" class="button small blue"/>
<span class="textfieldRequiredMsg"></span><span class="textfieldMaxCharsMsg">Maximum 40 characters.</span><span class="textfieldMinCharsMsg">Minimum 1 characters</span></span></td>
</tr>
<tr>
<td> </td>
<td>lastname : </td>
<td>
<span id="sprytextfield3">
<input name="lastname" type="text" maxlength="40" class="button small blue"/>
<span class="textfieldRequiredMsg"></span><span class="textfieldMinCharsMsg">Minimum 1 characters</span><span class="textfieldMaxCharsMsg">Maximum 40 characters</span></span></td>
</tr>
<tr>
<td> </td>
<td>password : </td>
<td>
<span id="sprypassword1">
<input name="password" type="password" maxlength="20" class="button small blue"/>
<span class="passwordRequiredMsg"></span><span class="passwordInvalidStrengthMsg">Password is not strength</span></span></td>
</tr>
<tr>
<td> </td>
<td>email : </td>
<td>
<span id="sprytextfield4">
<input name="email" type="text" maxlength="50" class="button small blue"/>
<span class="textfieldRequiredMsg"></span><span class="textfieldMinCharsMsg">Minimum 5 characters</span><span class="textfieldMaxCharsMsg">Maximum 50 characters</span><span class="textfieldInvalidFormatMsg">Invalid format</span></span></td>
</tr>
<tr>
<td> </td>
<td></td>
<td>
<input name="add" type="submit" value="Add" class="button small green"/>
<input name="Reset" type="reset" value="Reset" class="button small red"/></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
</form>
<? }?>
<div class="post_b"></div>
</div>
<div id="pagination">
<span class="alignleft"><a href="#"></a></span>
<span class="alignright"><a href="#"></a></span></div>
</div>
<div id="sidebar">
<center><br><font size="+1"><b>Welcome</b></font><br>
Administrator<br><br>
<?
echo "<a href=\"edit-profile-admin.php\">Edit Profile<br></a>";
echo "<a href=\"change-password-admin.php\">Change Password</a>";
?>
</center>
</div>
<?php /*?> <div id="digiclock"></div><?php */?>
<div class="clear"></div>
</div>
<div id="pagebottom"></div>
<div id="footer"></div>
</div>
<script type="text/javascript">
var sprytextfield1 = new Spry.Widget.ValidationTextField("sprytextfield1", "none", {minChars:2, maxChars:5, validateOn:["blur", "change"]});
var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "none", {validateOn:["blur", "change"], maxChars:40, minChars:1});
var sprypassword1 = new Spry.Widget.ValidationPassword("sprypassword1", {minNumbers:6, maxNumbers:20, validateOn:["blur", "change"]});
var sprytextfield3 = new Spry.Widget.ValidationTextField("sprytextfield3", "none", {validateOn:["blur", "change"], minChars:1, maxChars:40});
var sprytextfield4 = new Spry.Widget.ValidationTextField("sprytextfield4", "email", {validateOn:["blur", "change"], minChars:5, maxChars:50});
</script>
</body>
</html>
<?
}
else
{
echo "<meta http-equiv=\"refresh\" content=\"0;URL=index.php\"/>";
}
?>
ส่วนที่ผมอยากจะเช็คคือใน textfield ช่องแรกสุดเลยอะคับใน form นี้อะคับ คือผมลอง onSubmit onKeypress แล้วอะคับมันไม่ได้อะคับ
<form action="admin-add-work.php" method="post" id="addteach">
ขอบคุณมากคับ
Tag : PHP, JavaScript
|
|
|
|
|
|
Date :
2011-10-06 15:20:17 |
By :
sensitive |
View :
9171 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
แบบนี้หรือเปล่า
Code (PHP)
<script type="text/javascript">
<!--
function letter(e) {
var k;
document.all ? k = e.keyCode : k = e.which;
return ((k > 64 && k < 91) || (k > 96 && k < 123) || k == 8);
}
// -->
</script>
<form id="example" action="">
พิมพ์ได้เฉพาะภาษาอังกฤษ <input type="text" onkeypress="return letter(event)" />
</form>
|
|
|
|
|
Date :
2011-10-06 16:41:40 |
By :
nimporn |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วคับผมขอบคุณมากคับ
|
|
|
|
|
Date :
2011-10-06 21:14:12 |
By :
sensitive |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|