Peter
Junior Member
Coding God
Posts: 50
|
Post by Peter on Apr 29, 2006 13:34:43 GMT
Was a code request which may be useful for others.
If you want to stop user A PMing user B, then you would add both usernames into the array (bit in bold), so when one of them goes to PMing the other, the form will be disabled.
<script type="text/javascript"> <!--
// Array of the members who cannot PM each other var iMembers = ["username", "username", "username", "username"];
function preventPM(){ var gotUser = false;
for(m = 0; m < iMembers.length; m ++){ if(iMembers[m] == document.cookie.match(/\buser=(\w+)/)[1]){ gotUser = true; break; } }
for(m = 0; m < iMembers.length; m ++){ if(iMembers[m] == document.postForm.to.value && gotUser){ for(e = 0; e < document.postForm.elements.length; e ++){ if(document.postForm.elements.item(e).name == "to"){ continue; } document.postForm.elements.item(e).disabled = true; } break; } else { for(e = 0; e < document.postForm.elements.length; e ++){ document.postForm.elements.item(e).disabled = false; } } } }
if(document.postForm && location.href.match(/=pmsend/i)){ document.onkeypress = preventPM; document.onkeyup = preventPM; window.onload = preventPM; }
//--> </script>
Main footer
|
|