Tue 17 Jan 2006 08:21:51
รบกวนช่วยแก้โปรแกรมให้ทีครับ
คือผมได้ทำการเขียนฟอร์มเพื่อเช็คค่าต่างๆกับจาวาสคลิป การทำงานของฟอร์มคือ
เมื่อเราปล่อยค่าว่างตรงช่องให้เติมคำ ด้านกลุ่มชื่อ พอกดปุ่มSubmit ก็จะมีข้อความเตือนให้ใส่
ทีนี้ตรงที่ จากข้อ1-4 ถ้าไม่ทำการติ๊กถูกหรือเลือกจากเรดิโอในแต่ละข้อผมมะสามารถให้มัน
ขึ้นข้อความเตือนได้ อยากให้มีข้อความโชเตือนว่าคุณยังมะได้เลือกข้อนั้นๆไล่ลงมาเลื่อยๆ สำหรับข้อที่มะได้เลือก
แล้ว ถ้าข้อไหนมะได้เลือกให้มันไปเซ็ตโฟกัสที่ข้อ1ของแต่ละข้อที่มะได้เลือก(สำหรับข้อ1-4) *รบกวนแก้ให้ทีครับ
บักที่เกิดขึ้นกะโปรแกรม เช่น ถ้าข้อ1 ถ้าเรามะเลือกติ้กเรดิโอข้อสุดท้ายของข้อ1
ก็จะมะสามารถ พิมลงtextboxได้ แต่ถ้ามะได้เลือกแล้วก็จะมะสามารถพิมได้ บักมันอยู่ตรงที่พอเรา
พิมแล้ว แล้วไปกดปุ่ม reset โปรแกรมก็จะล้างสิ่งที่เราพิมไป และบักก็จะเกิดตรงที่
เราสามารถพิมได้เลยโดยที่มะต้องเลือกเลดิโอหน้าช่อง ซึ่งความต้องการต้องการให้
บังคับให้เลือกเลดิโอก่อนแล้วค่อยพิมได้ แต่พอกดปุ่มreset มันก็พิมได้เลย มันเกิดกับข้อ2 และข้อสุดท้ายด้วยครับ
รบกวนแก้บักให้ทีครับ
<html>
<head>
<title>แบบสอบถาม</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="../phithan.css" rel="stylesheet" type="text/css">
<script language="JavaScript">
<!--
var CurrentRadio
function ChangeState(formobject) {
if (formobject.disabled) {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadio(caller,formobject) {
if (caller.value == "อื่นๆ โปรดระบุ") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadioea(caller,formobject) {
if (caller.value == "ไม่แนะนำ เหตุผล ระบุ") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadioe(caller,formobject) {
if (caller.value == "รับรางวัลด้วยตนเอง") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function checkemail(text){
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(text)){
return true;
} else {
return false;
}
}
function checkhtml(text){
if (/<(.*)>.*<\/\1>/.test(text)){
return true;
} else {
return false;
}
}
function validateit(form){
if (form.name.value == ''){
alert("กรุณาใส่ชื่อจริงของคุณครับ");
form.name.focus();
return;
} else {
if (checkhtml(form.name.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.name.focus();
return;
}
}
if (form.sname.value == ''){
alert("กรุณาใส่นามสกุลของคุณครับ");
form.sname.focus();
return;
} else {
if (checkhtml(form.sname.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.sname.focus();
return;
}
}
if (form.home.value == ''){
alert("กรุณาใส่ที่อยู่ของท่านด้วยครับ");
form.home.focus();
return;
} else {
if (checkhtml(form.home.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.home.focus();
return;
}
}
if (form.mobli.value == ''){
alert("กรุณาใส่รหัสไปรษณีย์ของท่านด้วยครับ");
form.mobli.focus();
return;
} else {
if (checkhtml(form.mobli.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.mobli.focus();
return;
}
}
if (form.email.value == ''){
alert("กรุณาใส่อีเมล์ด้วยครับ");
form.email.focus();
return;
}else{
if (!checkemail(form.email.value)) {
alert("รูปแบบอีเมล์ไม่ถูกต้อง กรุณาตรวจสอบด้วยครับ");
form.email.focus();
return;
}
}
if (form.mobile.value == ''){
alert("กรุณาใส่เบอร์โทรศัพย์ของท่าน ด้วยครับ");
form.mobile.focus();
return;
} else {
if (checkhtml(form.mobile.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.mobile.focus();
return;
}
}
form.submit();
//alert("Submit")
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form id="root" name="root" method="post" action="form_pre.php">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" class="genblack">
<tr>
<td colspan="2"> <font color="#0066CC"><strong>1.</strong></font></td>
</tr>
<tr>
<td width="15%"> </td>
<td width="85%"><p>
<label>
<input name="pre3" type="radio" value="ทุกวัน" onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">ทุกวัน</font></label>
<br>
<label>
<input type="radio" name="pre3" value="มากกว่า 2 ครั้ง / สัปดาห์ "onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">มากกว่า 2 ครั้ง / สัปดาห</font>์</label>
<br>
<label>
<input type="radio" name="pre3" value="2 ครั้ง / สัปดาห์ "onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">2 ครั้ง / สัปดาห</font>์</label>
<br>
<label>
<input type="radio" name="pre3" value="นานๆ ครั้ง (เฉลี่ย 1 ครั้ง / เดือน)"onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">นานๆ ครั้ง (เฉลี่ย 1 ครั้ง / เดือน)</font></label>
<br>
<label>
<input type="radio" name="pre3" value="อื่นๆ โปรดระบุ"onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">อื่นๆ โปรดระบ</font>ุ</label>
<input name="pre3_1" type="text" id="pre3_1" size="40"disabled="true">
</p></td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>2.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><input name="pre4_1" type="checkbox" id="pre4_1" value="รูปแบบหน้าเว็บไซต์">
<font color="#006666">รูปแบบหน้าเว็บไซต์</font><br> <input name="pre4_2" type="checkbox" id="pre4_2" value="สีสัน">
<font color="#006666">สีสัน</font><br> <input name="pre4_3" type="checkbox" id="pre4_3" value="หมวดหมู่เนื้อหา">
<font color="#006666">หมวดหมู่เนื้อหา</font><br> <input name="pre4_4" type="checkbox" id="pre4_4" value="ความรู้เผยแพร่">
<font color="#006666">ความรู้เผยแพร่</font><br> <input name="pre4_5" type="checkbox" id="pre4_5" value="การให้บริการข่าวสารทางเว็บ">
<font color="#006666">การให้บริการข่าวสารทางเว็บ</font><br>
<input name="pre4_6" type="checkbox" id="pre4_6" value="อื่นๆ โปรดระบุ "onclick="ChangeState(pre4_7);">
<font color="#006666">อื่นๆ โปรดระบ</font>ุ
<input name="pre4_7" type="text" id="pre4_7" size="40"disabled="true"></td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>3.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><input name="pre5_1" type="checkbox" id="pre5_1" value="เคย">
<font color="#006666">เคย</font><br> <input name="pre5_2" type="checkbox" id="pre5_2" value="ไม่เคย">
<font color="#006666">ไม่เคย</font><br> <input name="pre5_3" type="checkbox" id="pre5_3" value="จะมาใช้บริการที่โชว์รูม">
<font color="#006666">จะมาใช้บริการที่โชว์รูม</font> </td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>4.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><p>
<label>
<input name="pre6" type="radio" value="พอใจมาก">
<font color="#006666">พอใจมาก</font></label>
<br>
<label>
<input type="radio" name="pre6" value="พอใจ">
<font color="#006666">พอใจ</font></label>
<br>
<label>
<input type="radio" name="pre6" value="เฉย/ปานกลาง">
<font color="#006666">เฉย/ปานกลาง</font></label>
<br>
<label>
<input type="radio" name="pre6" value="ไม่พอใจ ">
<font color="#006666">ไม่พอใจ</font></label>
</p></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> <table width="84%" border="0" cellpadding="0" cellspacing="0" class="genblack">
<tr>
<td width="27%"><font color="#0000FF">ชื่อ</font> </td>
<td width="73%">: <input name="name" type="text" id="name" size="30"></td>
</tr>
<tr>
<td><font color="#0000FF">นามสกุล</font></td>
<td>: <input name="sname" type="text" id="sname" size="30"></td>
</tr>
<tr>
<td><font color="#0000FF">ที่อยู่</font></td>
<td>: <input name="home" type="text" id="home" size="50"></td>
</tr>
<tr>
<td><font color="#0000FF">รหัสไปรษณีย์</font></td>
<td>: <input name="mobli" type="text" id="mobli" size="20"></td>
</tr>
<tr>
<td><font color="#0000FF">E-Mail</font></td>
<td>: <input name="email" type="text" id="email" size="40"></td>
</tr>
<tr>
<td><font color="#0000FF">เบอร์โทรศัพท์</font></td>
<td>: <input name="mobile" type="text" id="mobile" size="20"></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td height="45"> </td>
<td><p>
<label>
<input name="pre15" type="radio" value="จัดส่งทางไปรษณีย์" checked onclick="ChangeStateRadioe(this,pre15_1);">
<font color="#0000FF">จัดส่งทางไปรษณีย</font>์ </label>
<br>
<label>
<input type="radio" name="pre15" value="รับรางวัลด้วยตนเอง"onclick="ChangeStateRadioe(this,pre15_1);">
<font color="#0000FF">รับรางวัลด้วยตนเอง</font>
<select name="pre15_1" id="pre15_1"disabled="true">
<option value="">---เลือก---</option>
<option value="testจาวา1">testจาวา1</option>
<option value="testจาวา2">testจาวา2</option>
<option value="testจาวา3">testจาวา3</option>
</select>
</label>
</p></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><div align="center">
<input type="button" name="Submit" value="Submit" onclick="validateit(root);">
<input type="reset" name="Submit2" value="Reset">
</div></td>
</tr>
</table>
</form>
</body>
</html>
รบกวนด้วยนะครับ
ขอบคุณมากครับ
<html>
<head>
<title>แบบสอบถาม</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="../phithan.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript">
<!--
function ChangeState(formobject) {
if (formobject.disabled) {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadio(caller,formobject) {
if (caller.value == "อื่นๆ โปรดระบุ") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadioea(caller,formobject) {
if (caller.value == "ไม่แนะนำ เหตุผล ระบุ") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadioe(caller,formobject) {
if (caller.value == "รับรางวัลด้วยตนเอง") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function checkemail(text){
return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(text));
}
function checkhtml(text){
return (/<(.*)>.*<\/\1>/.test(text));
}
function clearForm(obj){
for(i = 0; i<obj.length; i++){
if(obj.elements[i].type == "radio" || obj.elements[i].type == "checkbox"){
obj.elements[i].checked = false;
}else if(obj.elements[i].type == "text"){
obj.elements[i].value = "";
}
}
pre3_1.disabled = true;
pre4_7.disabled = true;
pre15_1.disabled = true;
}
function validate(form){
if (form.name.value == ''){
alert("กรุณาใส่ชื่อจริงของคุณครับ");
form.name.focus();
return false;
}else if(checkhtml(form.name.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.name.focus();
return false;
}else if(form.sname.value == ''){
alert("กรุณาใส่นามสกุลของคุณครับ");
form.sname.focus();
return false;
}else if (checkhtml(form.sname.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.sname.focus();
return false;
}else if (form.home.value == ''){
alert("กรุณาใส่ที่อยู่ของท่านด้วยครับ");
form.home.focus();
return false;
}else if (checkhtml(form.home.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.home.focus();
return false;
}else if (form.mobli.value == ''){
alert("กรุณาใส่รหัสไปรษณีย์ของท่านด้วยครับ");
form.mobli.focus();
return false;
}else if (checkhtml(form.mobli.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.mobli.focus();
return false;
}else if (form.email.value == ''){
alert("กรุณาใส่อีเมล์ด้วยครับ");
form.email.focus();
return false;
}else if (!checkemail(form.email.value)) {
alert("รูปแบบอีเมล์ไม่ถูกต้อง กรุณาตรวจสอบด้วยครับ");
form.email.focus();
return false;
}else if (form.mobile.value == ''){
alert("กรุณาใส่เบอร์โทรศัพย์ของท่าน ด้วยครับ");
form.mobile.focus();
return false;
}else if (checkhtml(form.mobile.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.mobile.focus();
return false;
}
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form method="post" action="form_pre.php" onsubmit="return validate(this)">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" class="genblack">
<tr>
<td colspan="2"> <font color="#0066CC"><strong>1.</strong></font></td>
</tr>
<tr>
<td width="15%"> </td>
<td width="85%"><p>
<label>
<input type="radio" name="pre3" value="ทุกวัน" onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">ทุกวัน</font></label>
<br>
<label>
<input type="radio" name="pre3" value="มากกว่า 2 ครั้ง / สัปดาห์ "onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">มากกว่า 2 ครั้ง / สัปดาห</font>์</label>
<br>
<label>
<input type="radio" name="pre3" value="2 ครั้ง / สัปดาห์ "onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">2 ครั้ง / สัปดาห</font>์</label>
<br>
<label>
<input type="radio" name="pre3" value="นานๆ ครั้ง (เฉลี่ย 1 ครั้ง / เดือน)"onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">นานๆ ครั้ง (เฉลี่ย 1 ครั้ง / เดือน)</font></label>
<br>
<label>
<input type="radio" name="pre3" value="อื่นๆ โปรดระบุ"onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">อื่นๆ โปรดระบ</font></label>
<input name="pre3_1" type="text" id="pre3_1" size="40"disabled="true">
</p></td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>2.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><input name="pre4_1" type="checkbox" id="pre4_1" value="รูปแบบหน้าเว็บไซต์">
<font color="#006666">รูปแบบหน้าเว็บไซต์</font><br> <input name="pre4_2" type="checkbox" id="pre4_2" value="สีสัน">
<font color="#006666">สีสัน</font><br> <input name="pre4_3" type="checkbox" id="pre4_3" value="หมวดหมู่เนื้อหา">
<font color="#006666">หมวดหมู่เนื้อหา</font><br> <input name="pre4_4" type="checkbox" id="pre4_4" value="ความรู้เผยแพร่">
<font color="#006666">ความรู้เผยแพร่</font><br> <input name="pre4_5" type="checkbox" id="pre4_5" value="การให้บริการข่าวสารทางเว็บ">
<font color="#006666">การให้บริการข่าวสารทางเว็บ</font><br>
<input name="pre4_6" type="checkbox" id="pre4_6" value="อื่นๆ โปรดระบุ "onclick="ChangeState(pre4_7);">
<font color="#006666">อื่นๆ โปรดระบ</font>ุ
<input name="pre4_7" type="text" id="pre4_7" size="40"disabled="true"></td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>3.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><input name="pre5_1" type="checkbox" id="pre5_1" value="เคย">
<font color="#006666">เคย</font><br> <input name="pre5_2" type="checkbox" id="pre5_2" value="ไม่เคย">
<font color="#006666">ไม่เคย</font><br> <input name="pre5_3" type="checkbox" id="pre5_3" value="จะมาใช้บริการที่โชว์รูม">
<font color="#006666">จะมาใช้บริการที่โชว์รูม</font> </td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>4.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><p>
<label>
<input name="pre6" type="radio" value="พอใจมาก">
<font color="#006666">พอใจมาก</font></label>
<br>
<label>
<input type="radio" name="pre6" value="พอใจ">
<font color="#006666">พอใจ</font></label>
<br>
<label>
<input type="radio" name="pre6" value="เฉย/ปานกลาง">
<font color="#006666">เฉย/ปานกลาง</font></label>
<br>
<label>
<input type="radio" name="pre6" value="ไม่พอใจ ">
<font color="#006666">ไม่พอใจ</font></label>
</p></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> <table width="84%" border="0" cellpadding="0" cellspacing="0" class="genblack">
<tr>
<td width="27%"><font color="#0000FF">ชื่อ</font> </td>
<td width="73%">: <input name="name" type="text" id="name" size="30"></td>
</tr>
<tr>
<td><font color="#0000FF">นามสกุล</font></td>
<td>: <input name="sname" type="text" id="sname" size="30"></td>
</tr>
<tr>
<td><font color="#0000FF">ที่อยู่</font></td>
<td>: <input name="home" type="text" id="home" size="50"></td>
</tr>
<tr>
<td><font color="#0000FF">รหัสไปรษณีย์</font></td>
<td>: <input name="mobli" type="text" id="mobli" size="20"></td>
</tr>
<tr>
<td><font color="#0000FF">E-Mail</font></td>
<td>: <input name="email" type="text" id="email" size="40"></td>
</tr>
<tr>
<td><font color="#0000FF">เบอร์โทรศัพท์</font></td>
<td>: <input name="mobile" type="text" id="mobile" size="20"></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td height="45"> </td>
<td><p>
<label>
<input name="pre15" type="radio" value="จัดส่งทางไปรษณีย์" checked onclick="ChangeStateRadioe(this,pre15_1);">
<font color="#0000FF">จัดส่งทางไปรษณีย</font>์ </label>
<br>
<label>
<input type="radio" name="pre15" value="รับรางวัลด้วยตนเอง"onclick="ChangeStateRadioe(this,pre15_1);">
<font color="#0000FF">รับรางวัลด้วยตนเอง</font>
<select name="pre15_1" id="pre15_1"disabled="true">
<option value="">---เลือก---</option>
<option value="testจาวา1">testจาวา1</option>
<option value="testจาวา2">testจาวา2</option>
<option value="testจาวา3">testจาวา3</option>
</select>
</label>
</p></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><div align="center">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset" onclick="clearForm(this)">
</div></td>
</tr>
</table>
</form>
</body>
</html>
Fri 20 Jan 2006 09:51:36
โทษนะครับ โค้ดด้านบนที่แก้ให้มันยังติดบักอยู่เลยนะครับ
พอกดปุ่มresetมันขึ้น
ARuntime Error has occurred
Do you wish to Debug?
Line:53
Error:'pre3_1' is undefined
รบกวนช่วยแก้ให้ทีครับ
ขอบคุณมากครับ
Fri 20 Jan 2006 10:40:44
ขอโทษนะครับ รบกวนอีกนิด คือผมลองเอาโค้ดที่แก้ไขให้ไปลองtestดูแล้วนะครับ
ค่าที่ผมให้disabled="true"ใว้ พอกดปุ่มresetมันมะยอมdisabled เหมือนเดิมนะครับรบกวนแก้ไขให้ทีครับ คือพอผมกดปุ่มreset อยากให้ค่าที่ผมdisabledใว้ให้มันdisabledหลังจากกดปุ่มresetครับ
รบกวนด้วยนะครับ
ขอบคุณมากครับ
<html>
<head>
<title>แบบสอบถาม</title>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<link href="../phithan.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/javascript">
<!--
function ChangeState(formobject) {
if (formobject.disabled) {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadio(caller,formobject) {
if (caller.value == "อื่นๆ โปรดระบุ") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadioea(caller,formobject) {
if (caller.value == "ไม่แนะนำ เหตุผล ระบุ") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function ChangeStateRadioe(caller,formobject) {
if (caller.value == "รับรางวัลด้วยตนเอง") {
formobject.disabled = false;
} else {
formobject.value = "";
formobject.disabled = true;
}
}
function checkemail(text){
return (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(text));
}
function checkhtml(text){
return (/<(.*)>.*<\/\1>/.test(text));
}
function clearForm(obj){
for(i = 0; i<obj.length; i++){
if(obj.elements[i].type == "radio" || obj.elements[i].type == "checkbox"){
obj.elements[i].checked = false;
}else if(obj.elements[i].type == "text"){
obj.elements[i].value = "";
}
}
obj.pre3_1.disabled = true;
obj.pre4_7.disabled = true;
obj.pre15_1.disabled = true;
}
function validate(form){
if (form.name.value == ''){
alert("กรุณาใส่ชื่อจริงของคุณครับ");
form.name.focus();
return false;
}else if(checkhtml(form.name.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.name.focus();
return false;
}else if(form.sname.value == ''){
alert("กรุณาใส่นามสกุลของคุณครับ");
form.sname.focus();
return false;
}else if (checkhtml(form.sname.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.sname.focus();
return false;
}else if (form.home.value == ''){
alert("กรุณาใส่ที่อยู่ของท่านด้วยครับ");
form.home.focus();
return false;
}else if (checkhtml(form.home.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.home.focus();
return false;
}else if (form.mobli.value == ''){
alert("กรุณาใส่รหัสไปรษณีย์ของท่านด้วยครับ");
form.mobli.focus();
return false;
}else if (checkhtml(form.mobli.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.mobli.focus();
return false;
}else if (form.email.value == ''){
alert("กรุณาใส่อีเมล์ด้วยครับ");
form.email.focus();
return false;
}else if (!checkemail(form.email.value)) {
alert("รูปแบบอีเมล์ไม่ถูกต้อง กรุณาตรวจสอบด้วยครับ");
form.email.focus();
return false;
}else if (form.mobile.value == ''){
alert("กรุณาใส่เบอร์โทรศัพย์ของท่าน ด้วยครับ");
form.mobile.focus();
return false;
}else if (checkhtml(form.mobile.value)){
alert("กรุณางดใช้แท็ก HTML ในฟอร์มนี้ด้วยครับ");
form.mobile.focus();
return false;
}
}
//-->
</script>
</head>
<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<form method="post" action="form_pre.php" onSubmit="return validate(this)">
<table width="700" border="0" align="center" cellpadding="0" cellspacing="0" class="genblack">
<tr>
<td colspan="2"> <font color="#0066CC"><strong>1.</strong></font></td>
</tr>
<tr>
<td width="15%"> </td>
<td width="85%"><p>
<label>
<input type="radio" name="pre3" value="ทุกวัน" onClick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">ทุกวัน</font></label>
<br>
<label>
<input type="radio" name="pre3" value="มากกว่า 2 ครั้ง / สัปดาห์ "onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">มากกว่า 2 ครั้ง / สัปดาห</font>์</label>
<br>
<label>
<input type="radio" name="pre3" value="2 ครั้ง / สัปดาห์ "onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">2 ครั้ง / สัปดาห</font>์</label>
<br>
<label>
<input type="radio" name="pre3" value="นานๆ ครั้ง (เฉลี่ย 1 ครั้ง / เดือน)"onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">นานๆ ครั้ง (เฉลี่ย 1 ครั้ง / เดือน)</font></label>
<br>
<label>
<input type="radio" name="pre3" value="อื่นๆ โปรดระบุ"onclick="ChangeStateRadio(this,pre3_1);">
<font color="#006666">อื่นๆ โปรดระบ</font></label>
<input name="pre3_1" type="text" id="pre3_1" size="40"disabled="true">
</p></td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>2.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><input name="pre4_1" type="checkbox" id="pre4_1" value="รูปแบบหน้าเว็บไซต์">
<font color="#006666">รูปแบบหน้าเว็บไซต์</font><br> <input name="pre4_2" type="checkbox" id="pre4_2" value="สีสัน">
<font color="#006666">สีสัน</font><br> <input name="pre4_3" type="checkbox" id="pre4_3" value="หมวดหมู่เนื้อหา">
<font color="#006666">หมวดหมู่เนื้อหา</font><br> <input name="pre4_4" type="checkbox" id="pre4_4" value="ความรู้เผยแพร่">
<font color="#006666">ความรู้เผยแพร่</font><br> <input name="pre4_5" type="checkbox" id="pre4_5" value="การให้บริการข่าวสารทางเว็บ">
<font color="#006666">การให้บริการข่าวสารทางเว็บ</font><br>
<input name="pre4_6" type="checkbox" id="pre4_6" value="อื่นๆ โปรดระบุ "onclick="ChangeState(pre4_7);">
<font color="#006666">อื่นๆ โปรดระบ</font>ุ
<input name="pre4_7" type="text" id="pre4_7" size="40"disabled="true"></td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>3.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><input name="pre5_1" type="checkbox" id="pre5_1" value="เคย">
<font color="#006666">เคย</font><br> <input name="pre5_2" type="checkbox" id="pre5_2" value="ไม่เคย">
<font color="#006666">ไม่เคย</font><br> <input name="pre5_3" type="checkbox" id="pre5_3" value="จะมาใช้บริการที่โชว์รูม">
<font color="#006666">จะมาใช้บริการที่โชว์รูม</font> </td>
</tr>
<tr>
<td colspan="2"> <font color="#0066CC"><strong>4.</strong></font></td>
</tr>
<tr>
<td> </td>
<td><p>
<label>
<input name="pre6" type="radio" value="พอใจมาก">
<font color="#006666">พอใจมาก</font></label>
<br>
<label>
<input type="radio" name="pre6" value="พอใจ">
<font color="#006666">พอใจ</font></label>
<br>
<label>
<input type="radio" name="pre6" value="เฉย/ปานกลาง">
<font color="#006666">เฉย/ปานกลาง</font></label>
<br>
<label>
<input type="radio" name="pre6" value="ไม่พอใจ ">
<font color="#006666">ไม่พอใจ</font></label>
</p></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> </td>
<td> <table width="84%" border="0" cellpadding="0" cellspacing="0" class="genblack">
<tr>
<td width="27%"><font color="#0000FF">ชื่อ</font> </td>
<td width="73%">: <input name="name" type="text" id="name" size="30"></td>
</tr>
<tr>
<td><font color="#0000FF">นามสกุล</font></td>
<td>: <input name="sname" type="text" id="sname" size="30"></td>
</tr>
<tr>
<td><font color="#0000FF">ที่อยู่</font></td>
<td>: <input name="home" type="text" id="home" size="50"></td>
</tr>
<tr>
<td><font color="#0000FF">รหัสไปรษณีย์</font></td>
<td>: <input name="mobli" type="text" id="mobli" size="20"></td>
</tr>
<tr>
<td><font color="#0000FF">E-Mail</font></td>
<td>: <input name="email" type="text" id="email" size="40"></td>
</tr>
<tr>
<td><font color="#0000FF">เบอร์โทรศัพท์</font></td>
<td>: <input name="mobile" type="text" id="mobile" size="20"></td>
</tr>
</table></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td height="45"> </td>
<td><p>
<label>
<input name="pre15" type="radio" value="จัดส่งทางไปรษณีย์" checked onClick="ChangeStateRadioe(this,pre15_1);">
<font color="#0000FF">จัดส่งทางไปรษณีย</font>์ </label>
<br>
<label>
<input type="radio" name="pre15" value="รับรางวัลด้วยตนเอง"onclick="ChangeStateRadioe(this,pre15_1);">
<font color="#0000FF">รับรางวัลด้วยตนเอง</font>
<select name="pre15_1" id="pre15_1"disabled="true">
<option value="">---เลือก---</option>
<option value="testจาวา1">testจาวา1</option>
<option value="testจาวา2">testจาวา2</option>
<option value="testจาวา3">testจาวา3</option>
</select>
</label>
</p></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><div align="center">
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Submit2" value="Reset" onClick="clearForm(this.form)">
</div></td>
</tr>
</table>
</form>
</body>
</html>
Mon 23 Jan 2006 08:59:51
ขอบคุณมากครับ

















