|
 |
|
สอบถามเกี่ยวกับการเรียกฟังก์ชั่น javascript หน่อยครับ (ขออนุญาติตั้งกระทู้ใหม่) |
|
 |
|
|
 |
 |
|
Code (PHP)
<script language="JavaScript">
function fncSubmit()
{
if(document.frmNewTopic.txtEmail.value == "")
{
alert('กรุณาระบุ Email ผู้ตั้งกระทู้ด้วยค่ะ');
document.frmNewTopic.txtEmail.focus();
return false;
}
var emailFilter=/^.+@.+\..{2,3}$/;
var str=document.frmNewTopic.txtEmail.value;
if (!(emailFilter.test(str)))
{
alert ("ท่านใส่อีเมล์ไม่ถูกต้อง");
document.frmNewTopic.txtEmail.focus();
return false;
}
document.frmNewTopic.submit();
}
</script>
<form action="" method="post" name="frmNewTopic" id="frmNewTopic" onSubmit="JavaScript:return fncSubmit();">
Email :
<input name="txtEmail" type="text" class="common_black_13px" id="txtEmail" size="50"/>
</form>
น่าจะประมาณนี้อ่ะครับ ลองดูนะครับ
|
 |
 |
 |
 |
Date :
2011-04-07 11:42:25 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
แล้วถ้าผมจะเรียกใช้ สองฟังก์ชั่นอ่ะครับ มันสามารถทำได้มั้ยCode (PHP)
<td><form action="orderdetail.php" method="post" name="form1" id="form1" onsubmit="return check_email(),check();" >
แบบนี้อ่ะครับ
|
 |
 |
 |
 |
Date :
2011-04-07 11:53:57 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ปัญหาของผมคือมันเรียกใช้งานได้อ่ะครับ แต่คือผมเรียกใช้อีกฟังก์ชั่นนึงด้วย ถ้ามันเช็คอีเมล์ มันจะไม่ยอมเช็คเบอร์โทรศัพท์ อยู่ที่ว่าผมเรียก ฟังก์ชั่นไหนก่อน งงมากๆเลยครับ ไม่เคยใช้แบบนี้มาก่อน ปกติใช้ tools เขียนมาตลอด
|
 |
 |
 |
 |
Date :
2011-04-07 12:00:45 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยด้วยครับผม
|
 |
 |
 |
 |
Date :
2011-04-07 14:09:48 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ตามมาเอาใจช่วย
|
 |
 |
 |
 |
Date :
2011-04-07 14:12:43 |
By :
keapkung |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<script language="JavaScript">
function fncSubmit()
{
if(document.frmNewTopic.txtEmail.value == "")
{
alert('กรุณาระบุ Email ผู้ตั้งกระทู้ด้วยค่ะ');
document.frmNewTopic.txtEmail.focus();
return false;
}
var emailFilter=/^.+@.+\..{2,3}$/;
var str=document.frmNewTopic.txtEmail.value;
if (!(emailFilter.test(str)))
{
alert ("ท่านใส่อีเมล์ไม่ถูกต้อง");
document.frmNewTopic.txtEmail.focus();
return false;
}
document.frmNewTopic.submit();
}
function checkNumber(elm){
if(elm.value.match(/[^\\d]/)){
alert('กรอกตัวเลขเท่านั้น');
elm.value='';
}
}
</script>
<form action="" method="post" name="frmNewTopic" id="frmNewTopic" onSubmit="JavaScript:return fncSubmit();">
Email : ([email protected])<br />
<input name="txtEmail" type="text" id="txtEmail" size="50"/><br />
Mobile : (number only)<br />
<input name="txtMobile" type="text" id="txtMobile" size="50" onkeyup='checkNumber(this)'/><br />
</form>
ลองดูนะครับ     
ปล. "function checkNumber" credit : xbeginner01 ครับ
|
 |
 |
 |
 |
Date :
2011-04-07 14:56:16 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
check number ใช้ไม่ได้อ่ะครับ กรอกตัวเลข ก้ alert
|
 |
 |
 |
 |
Date :
2011-04-07 15:07:31 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ที่จริงตัว check เบอร์ผมมีแล้วแหละครับ แต่พอพิมผิด กด submit มันก็ขึ้น alert แต่มันไม่ยอมให้พิมใหม่ ยังไงช่วยลองเข้าไปดูหน่อยนะครับ
pukpui.com/cat/no.php
Code (JavaScript)
function CheckMobileNumber(data) {
var msg = 'โปรดกรอกหมายเลขโทรศัพท์ 10 หลัก ด้วยรูปแบบดังนี้ 08XXXXXXXX ไม่ต้องใส่เครื่องหมายขีด (-) วงเล็บหรือเว้นวรรค';
s = new String(data);
if ( s.length != 10)
{
alert(msg);
return false;
}
for (i = 0; i < s.length; i++ ) {
if ( s.charCodeAt(i) < 48 || s.charCodeAt(i) > 57 ) {
alert(msg);
return false;
} else {
if ( ((i == 0) && (s.charCodeAt(i) != 48)) || ((i == 1) && (s.charCodeAt(i) != 56)) )
{
alert(msg);
return false;
}
}
}
// return true;
|
 |
 |
 |
 |
Date :
2011-04-07 15:10:05 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็กลับไปคีย์ได้นี่ครับ...
|
 |
 |
 |
 |
Date :
2011-04-07 15:22:31 |
By :
pokultra |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
กด back กลับไปได้ แต่มัน add ลง database ไปแล้วอ่ะครับ
|
ประวัติการแก้ไข 2011-04-07 15:26:10
 |
 |
 |
 |
Date :
2011-04-07 15:23:54 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
อยากให้มันขึ้น alert แล้วให้พิมพ์ใหม่ในหน้านั้นเลย เหมือนตอนใส่ email ผิดอะครับ
|
 |
 |
 |
 |
Date :
2011-04-07 15:38:16 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
T^T
|
 |
 |
 |
 |
Date :
2011-04-07 17:02:29 |
By :
ZieIw |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 03
|