We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
changing function...javascript.
Topic Started: Nov 14 2007, 03:01 AM (499 Views)
Mistagnerd
Member
[ * ]
Ok i'm trying to change the onsubmit validate() function that is executed when a person registers...so this is the code i'm using...

Code:
 
<script type="text/javascript">
if(location.href.match(/act=Reg&CODE/i)){
 b=document.getElementsByTagName("form");
 for(i=0;i<b.length;i++){
 b[i].setAttribute('onsubmit','return Validate2()');
 }
}
</script>


but for some reason its not working...anyone know why?
Offline Profile Quote Post Goto Top
 
Arrogant
Member Avatar
Member
[ *  *  *  * ]
Code:
 
<script type="text/javascript">
if(document.REG) {
   function iLoveHinata() {
      alert("no");
      return false;
   }
   document.REG.onsubmit = iLoveHinata;
}
</script>


- Validate() already returns true or false, so i don't see why they even have "return Validate()" in there. >.<
- when putting a function for an "on"-event type thing, you don't include the ()'s. those execute the function, but you want the funciton to be executed when the "on"-event occurs.
- document.REG > document.getElementsByTagName("form") + for loops.
- ^^ same with the location check thing. pffft. :P


----

here's an easier way (don't know if it causes errors though):

Code:
 
<script type="text/javascript">
if(document.REG) {
   function Validate() {
      alert("no");
      return false;
   }
}
</script>


just re-define the function itself. of course, you're going to have to have SOMETHING returned, but i think you already know that.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Technology Chat · Next Topic »
Add Reply