PDA

View Full Version : Quick PM Reply Box, quy ðịnh kí tự it nhât khi post bài


LSB-Tế Công
28-11-2004, 12:44
<script>
// Quick PM Reply Box - Leave Copyright Intact Wherever Used
// Created For Invision Free
// Author: Zero Tolerance © Game Zone | Evolution 2004 [http://gzevolution.net]
if(location.href.match(/act=Msg&CODE=(\d+)&VID=(\w+)&MSID=(\d+)/i)){
function ValidateForm(isMsg){MessageMax="";Override="";
MessageMax=parseInt(MessageMax);
if( MessageMax < 0 ){MessageMax = 0;}
MessageLength = document.REPLIER.Post.value.length;
errors = "";if(isMsg==1){
if(document.REPLIER.msg_title.value.length < 2){
errors = "You must enter a message title";}}
if (MessageLength < 2){errors = "You must enter a vMessageMax) {
errors = "The maximum allowed length is " + MessageMax + " characters. Current Characters: " + MessageLength;}}
if (errors != "" && Override == "") {alert(errors);
return false;} else {document.REPLIER.submit.disabled = true;return true;}}
url=location.href.split('/')[4];url=location.href.replace(url,'')
pmReplyBox="<br><div class='tableborder'><div class='titlemedium'>Quick PM Reply Box</div>"
pmReplyBox+="<form action='"+url+"' method='post' name='REPLIER' onsubmit='return ValidateForm(1)'>"
pmReplyBox+="<input type='hidden' name='act' value='Msg' /><input type='hidden' name='CODE' value='04' />"
pmReplyBox+="<input type='hidden' name='MODE' value='01' /><input type='hidden' name='entered_name' value='{toUser}'/>"
pmReplyBox+="<input type='hidden' name='carbon_copy' value=''/>"
pmReplyBox+="<input type='hidden' name='msg_title' value='Re: {theTitle}'/>"
pmReplyBox+="<table width='100%' cellpadding='3' cellspacing='1'><tr><td width='20%' valign='top' class='row1'><b>Your Reply:</b></td>"
pmReplyBox+="<td width='80%' valign='top' class='row1'><textarea rows='7' cols='60' name='Post'></textarea>"
pmReplyBox+="</tr><tr><td colspan='2' class='row1'>"
pmReplyBox+="<input type='checkbox' name='add_sent' value='no'/>&nbsp;<b>Add a copy of this message to my sent items folder</b>"
pmReplyBox+="<br /><input type='checkbox' name='add_tracking' value='1' />&nbsp;<b>Track this message?</b>"
pmReplyBox+="</td></tr><tr><td align='center' colspan='2' class='row2'><input type='submit' value='Send Reply' class='forminput' name='submit'></td>"
pmReplyBox+="</tr></table></div><br></form>"
div=document.getElementsByTagName('div')
for(d=0;d<div.length;d++){
if(div[d].className=="titlemedium" && div[d].innerHTML=="&nbsp;&nbsp;Personal Message"){
MainNode=div[d].parentNode;Span=MainNode.getElementsByTagName('sp an')
User=Span[0].getElementsByTagName('a')[0].innerHTML
Title=Span[1].getElementsByTagName('b')[0].innerHTML
Title=Title.replace(/Re: /gi,'')
pmReplyBox=pmReplyBox.replace('{toUser}',User)
pmReplyBox=pmReplyBox.replace('{theTitle}',Title)
div[d].parentNode.outerHTML+=pmReplyBox}}}
</script>

HAC THIEN LONG
24-01-2005, 17:31
cái này thì paste ở đâu??
sao đệ làm mãi không được??

LSB-Tế Công
26-01-2005, 09:36
cái này hả để nhớ xem hình như là java hay food thì phải thử từng cái coi , tui xài rồi nhưng thấy bất tiện quá nên xoá rồi lâu ngày cũng quên !!!

Mắt Đêm
26-01-2005, 18:34
Rách việc quá, đâu cần cái gì dài dòng đâu! http://www.luongsonbac.com/forum/images/smilie/icon_smile.gif

Nếu muốn quy định số kí tự ít nhất khi post bài, dùng 1 đoạn javascript ngắn cũn là xong:

- Đặt tên cho cái form chứa cái textarea (tên là "doviet" chẳng hạn http://www.luongsonbac.com/forum/images/smilie/09.gif), còn cái textarea ấy thì đặt 1 cái tên khác ("doviettext" chẳng hạn http://www.luongsonbac.com/forum/images/smilie/icon_biggrin.gif).
- Chèn đoạn script này vào trong header:

<script language="javascript">
<!--
var minlength = 10; // Thay đổi giá trị này tùy ý!
if (window.document.doviet.doviettext.value.length < minlength)
{
alert('Noi dung bai viet cua ban phai dai hon 10 ki tu!');
return false;
}
-->
</script>

Đấy thế thôi. Em mới viết chứ chưa thử, nếu thử mà sai thì bảo em, em sửa lại http://www.luongsonbac.com/forum/images/smilie/icon_smile.gif