It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming JavaScript Forum

err msg: subscribeForm is null or not defined.....Why???

err msg: subscribeForm is null or not defined.....Why???

Postby thehurricane on Thu Jul 03, 2008 8:25 am

So, I made this script which would check if the email address entered is in the correct form. But I get an error message 'Cannot convert undefined or null to an object'.

Code: Select all
var pageLoaded = 0;
var subscribeForm;

window.onload = function() {pageLoaded = 1;}


//This function waits for the elements to load then executes the get_txtbox function
function loader(i,f) {
  var j;
  if (document.getElementById && document.getElementById(i) != null)
  {
    j = document.getElementById(i);
    f(j);
  }
  else if (!pageLoaded) setTimeout('loader(\''+i+'\','+f+')',100);
}

//This function starts if an element with ID subscribeForm exists & the element is passed on to variable subscribeForm through an arguement
function get_txtBox(subscribeForm) {
//The startValidate function is called at the end of the get_txtbox function.
  var email_txtBox;
  function startValidate(email_txtBox) {
//I have the problem below. Browser says subscribeForm is undefined or null. This function does all the checking stuff.
    subscribeForm.onsubmit = function() {
      function echeck(str) {
        var at="@"
        var dot="."
        var lat=str.indexOf(at)
        var lstr=str.length
        var ldot=str.indexOf(dot)

        if (str.indexOf(at)==-1) {
          alert("Invalid E-mail ID")
          return false
        }

        if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr) {
          alert("Invalid E-mail ID")
          return false
        }

        if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr) {
          alert("Invalid E-mail ID")
          return false
        }

        if (str.indexOf(at,(lat+1))!=-1) {
          alert("Invalid E-mail ID")
          return false
        }

        if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot) {
          alert("Invalid E-mail ID")
          return false
        }

        if (str.indexOf(dot,(lat+2))==-1) {
          alert("Invalid E-mail ID")
          return false
        }
      
        if (str.indexOf(" ")!=-1){
          alert("Invalid E-mail ID")
          return false
        }

        return true               
      }

      var emailID=document.subscribeForm.email_txtBox

      if ((emailID.value==null)||(emailID.value=="")){
        alert("Please Enter your Email ID");
        emailID.focus();
        return false;
      }

      else if (echeck(emailID.value)==false) {
        emailID.focus();
        return false;
      }

      else {
        window.open('http://www.feedburner.com/fb/a/emailverifySubmit?feedId=1969288', 'popupwindow', 'scrollbars=yes,width=550,height=520');
      }
    }
  }

  loader('email_txtBox',startValidate);
}

//Starts the function which checks for existence of elements (at the top)
loader('subscribeForm',get_txtBox);



And this is the HTML.
Code: Select all
<form  method="post" name="subscribeForm" id="subscribeForm" action="http://www.feedburner.com/fb/a/emailverify"  target="popupwindow">
  <input name="email_txtBox" id="email_txtBox" type="text" value="" />
  <input name="send_btn" id="send_btn" type="submit" value="" />
</form>


I know I made the function all complex but I couldn't think of anything else.
And yeah, even though I get the error but still on submitting the form I get the alert boxes from subscribeForm.onsubmit. I'm totally confused.:confused:
thehurricane
 
Posts: 0
Joined: Thu Jul 03, 2008 8:20 am

Starting internet dating agency. Dating a younger guy.

Postby tokgeonobutle on Thu Dec 01, 2011 12:03 pm

Adult video live asian chat rooms, contact dating free online service. Sex dating in redmond utah.
A2z russian women. Reserved dating across the states, avery dating idaho jewish service.
Dating eastville, dating lineboro. Free online chat rooms for dating.
Dating rollins fork. Teen dating guidlines, dating otho.
Switzerland online dating site, dating merrillan. Lorenza lamas dating.
tokgeonobutle
 
Posts: 3
Joined: Thu Dec 01, 2011 7:54 am
Location: America


Who is online

Users browsing this forum: No registered users and 5 guests