|
 |
|
ขอสอบถามเกี่ยวกับ Java Script ในการตรวจสอบให้พิมพ์ได้เฉพาะตัวอักษรภาษาอังกฤษ และภาษาไทยรวมถึงพยัญชนะ ด้วยครับ แต่ไม่ให้ใส่ตัวเลข |
|
 |
|
|
 |
 |
|

|
 |
 |
 |
 |
Date :
2012-01-17 12:50:28 |
By :
DonutJung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ไม่ใครรู้บ้างครับ ติดนิดเดียวครับ ลองเซิจดูแล้วไม่เจอเลยครับ
|
 |
 |
 |
 |
Date :
2012-01-17 15:05:03 |
By :
DonutJung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
เปลี่ยนตรง
if(!elem.match(/^([a-zก-ฮ\_])+$/i))
เป็น
if(elem.match(/[0-9]/i))
|
 |
 |
 |
 |
Date :
2012-01-17 16:05:17 |
By :
amuropao08 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณครับ AmuroPao08 แต่ผมต้องการให้ไม่สามารถพิมพ์ตัวเลขได้อะครับ นอกนั้นพิมพ์ได้หมดทุกตัวอะครับทั้งภาษาไทย รวมถึงสระ และภาษาอังกฤษ พอรู้บ้างเปล่าคับ ขอบคุณครับ
|
 |
 |
 |
 |
Date :
2012-01-17 16:18:30 |
By :
DonutJung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่ผมให้ไปใช้ไม่ได้หรือครับ
เพราะผมเช็คว่าถ้าค่าที่กรอกมามี 0-9 ปนมาด้วย ให้ alert น่ะครับ
|
 |
 |
 |
 |
Date :
2012-01-17 16:51:20 |
By :
amuropao08 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<script type="text/javascript">
<!--
function checkText()
{
var elem = document.getElementById('test_txt').value;
if(elem.match(/[0-9]/i))
{
alert("กรอกได้เฉพาะ a-Z, A-Z, ก-ฮ และ _ (underscore)");
document.getElementById('test_txt').value = "";
}
}
//-->
</script>
<input type="text" name="test_txt" id="test_txt" onkeypress="checkText();" value=""/>
ขอให้ประโยชน์จงเกิดแก่ท่าน
|
 |
 |
 |
 |
Date :
2012-01-17 20:41:49 |
By :
โปรแกรมเมอร์ฝึกหัด |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากเลยครับ AmuroPao08 ขอโทษจริงๆ ครับ ผิดพลาดนิดหน่อย 555+ ได้แล้วครับ 
|
 |
 |
 |
 |
Date :
2012-01-18 09:13:15 |
By :
DonutJung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
function checkText()
{
var elem = document.getElementById('test_txt').value;
if(!elem.match(/^([a-zก-ฮ\_])+$/i))
{
alert("กรอกได้เฉพาะ a-Z, A-Z, ก-ฮ และ _ (underscore)");
document.getElementById('test_txt').value = "";
}
}
<input type="text" name="test_txt" id="test_txt" onblur="checkText();" value=""/>
อยากทราบว่าโค้ดนี้ที่ให้มาทำไมเวลาพิมพ์ตัวอักษรได้น้อยมากคะ ช่วยตอบที่คะ
|
 |
 |
 |
 |
Date :
2012-03-02 22:39:36 |
By :
ปู |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 01
|