All pastes #808589 Raw Edit

Anonymous

public html v1 · immutable
·published 2007-12-07 19:13 UTC
rendered paste body
#Problem: the TD with id "email_error" does not display anything when I try to apply innerHTML text to it#My javascript below// Validation Code v2.0 (By Murdoc)function validate_form(){	var status = true;  if ( user_check() == false ){      status = false;      alert ("user not ok");    }  if ( email_check() == false ){      status = false;      document.getElementById('email_error').innerHTML = 'error';      alert ('email');    }  if ( pw_check() == false ){      status = false;      alert ('pw');    }  if ( confirm_pw_check() == false ){      status = false;      alert ('confirm pw');    }  if ( vcode_check() == false ){      status = false;      alert ('vcode');    }    alert ('status' + status);    return status;}function validate_email (email){var regex =/^[\w\-\.\+]+\@[a-zA-Z0-9\.\-]+\.[a-zA-Z0-9]{2,3}$/;  if (email.value.match(regex)){       return true;  }else{    return false;  }}function pw_check(){var pw = document.getElementById('pw'); if (pw.value.length < 6 || pw.value.length > 32){ //password check      document.getElementById('pw_error').innerHTML =                                   '<span style="color:red">Please enter a 6 - 32 character password</span>';      return false;  }else{  document.getElementById('pw_error').innerHTML ='';  }}function confirm_pw_check(){var pw = document.getElementById('pw');var confirm_pw = document.getElementById('confirm_pw');  if (confirm_pw.value.length==0){ //Confim pw check      document.getElementById('confirm_pw_error').innerHTML =                                         '<span style="color:red">Please re-enter the password</span>';      return false;  }else{  document.getElementById('confirm_pw_error').innerHTML ='';  }  if (confirm_pw.value != pw.value){//pw match check      document.getElementById('confirm_pw_error').innerHTML =                             '<span style="color:red">Passwords did not match</span>';      confirm_pw.value="";      return false;  } }function validate_user (uname){var regex =/^[\w\-\.]+$/;  if (uname.value.match(regex)){    return true;  }else{    return false;  }}function initial_focus (){    var uname = document.getElementById("user");  uname.focus();}function user_check() {//checks if user name field is empty  var uname = document.getElementById("user");    if (uname.value.length==0){//username check       document.getElementById('username_error').innerHTML = '<span style="color:red">Please enter a username</span>';       return false;    }    else if (validate_user(uname)==false){      document.getElementById('username_error').innerHTML=                   '<span style="color:red">you can only use: "_", "-" and "." as special characters</span>';      return false;    }//performs ajax request  var ajaxRequest;    try{    //FF, opera, safari      ajaxRequest=new XMLHttpRequest();    }    catch (e){    try{      ajaxRequest = new ActiveXObject("Msxm12.XMLHTTP");    }catch (e){      try{         ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");      }catch (e){              alert("Your broser does not support AJAX");         return false;      }    }  }      	// Create a function that will receive data sent from the server	ajaxRequest.onreadystatechange = function(){		if(ajaxRequest.readyState == 4){	  document.getElementById('username_error').innerHTML = ajaxRequest.responseText;		var msg = ajaxRequest.responseText;		   //alert(msg);		var trueFalse;		if (msg == '<span style="color:red">Username already exists</span>'){			trueFalse = false;		}else{		  trueFalse = true;		}		document.write(msg);		return trueFalse;		}	}        var uname=document.registration_form.user.value;        var query_string = "?user=" + uname;	ajaxRequest.open("GET", "lib/ajax_user_check.php" + query_string, true);	ajaxRequest.send(null); }function email_check() {var status = true;var email = document.getElementById('email');    if (email.value.length==0){//Email check      document.getElementById('email_error').innerHTML =                                             '<span style="color:red">Please enter your email address</span>';      status = false;    }    else if (validate_email(email)==false){//email validation        document.getElementById('email_error').innerHTML=                                        '<span style="color:red">please enter a valid email address</span>';        status = false;    }    var ajaxRequest;try{  //FF, opera, safari   ajaxRequest=new XMLHttpRequest();}catch (e){    try    {    ajaxRequest = new ActiveXObject("Msxm12.XMLHTTP");    }    catch (e)    {      try        {          ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");        }        catch (e)        {                alert("Your broser does not support AJAX");          status = false;          }        }      }      	// Create a function that will receive data sent from the server	ajaxRequest.onreadystatechange = function(){		if(ajaxRequest.readyState == 4){                  document.getElementById('email_error').innerHTML = ajaxRequest.responseText;                  //alert(document.getElementById('email_error').innerHTML);                  var msg = document.getElementById('email_error').innerHTML;                  if (msg ==                       '<span style="color:red">Email already exists. Have you forgotten your pw?</span>')                  {                   status = false;                  }		}	}        var email=document.getElementById('email').value;        var query_string = "?email=" + email;	ajaxRequest.open("GET", "lib/ajax_email_check.php" + query_string, true);	ajaxRequest.send(null);   return status;}    function vcode_check() { var vcode = document.getElementById('image_code');    if (vcode.value.length==0){//Vcode check      document.getElementById('vcode_error').innerHTML =                                             '<span style="color:red">Please enter image text</span>';      return false;    }else{        document.getElementById('vcode_error').innerHTML =''    }        var ajaxRequest;try{  //FF, opera, safari   ajaxRequest=new XMLHttpRequest();}catch (e){    try    {    ajaxRequest = new ActiveXObject("Msxm12.XMLHTTP");    }    catch (e)    {      try        {          ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");        }        catch (e)        {                alert("Your broser does not support AJAX");          return false;          }        }      }      	// Create a function that will receive data sent from the server	ajaxRequest.onreadystatechange = function(){		if(ajaxRequest.readyState == 4){                  document.getElementById('vcode_error').innerHTML = ajaxRequest.responseText;                  //alert(document.getElementById('email_error').innerHTML);                  var msg = document.getElementById('vcode_error').innerHTML;                  if (msg ==                       '<span style=\"color:red\">Invalid VCode entry</span>')                  {                   return false;                  }                  else                  {                   return true;                  }		}	}        var query_string = "?vcode=" + vcode.value;	ajaxRequest.open("GET", "lib/ajax_vcode_check.php" + query_string, true);	ajaxRequest.send(null);     }function reset_error_msg(){  document.getElementById('username_error').innerHTML ='';  document.getElementById('pw_error').innerHTML ='';  document.getElementById('confirm_pw_error').innerHTML ='';  document.getElementById('email_error').innerHTML ='';  document.getElementById('vcode_error').innerHTML ='';  }  #My HTML below<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"><head><?php require($conf_t['header_tpl']) ?><link rel="stylesheet" type="text/css" href="<?php echo $conf_t['register_css']; ?>" media="screen" /><script type="text/javascript" src="<?php echo $conf_t['register_js'];?>"></script><title>Telephone Blacklist - Registration</title></head><body onload="initial_focus()"><?php require($conf_t['tb_banner_tpl']) ?><p style="text-align:left">Please read our <a style="text-decoration:underline" href="index.php?a=11">terms and conditions</a> before registering.<br /> By submitting this form, you agree to abide by the <br />terms of use and services as stated.</p><div id="main_align"><form method="post" action="index.php" id="registration_form" onreset="reset_error_msg()" onsubmit="return validate_form()"><fieldset><legend> Registration Form</legend>  <table style="text-align:left" cellpadding="1" cellspacing="2" id="registration_form1">    <tr><td colspan="2" id="username_error"></td></tr>    <tr><td><span style="color:red">*</span> username:</td><td><input type="text" id="user" size="22" maxlength="32" /></td></tr>  <tr><td colspan="2" id="email_error"></td></tr>  <tr><td><span style="color:red">*</span> Email:</td><td><input type="text" id="email" size="22" maxlength="128" /></td></tr>  <tr><td colspan="2" id="pw_error"></td></tr>  <tr><td><span style="color:red">*</span> Password:</td><td><input type="password" id="pw" size="22" maxlength="42" /></td></tr>  <tr><td colspan="2" id="confirm_pw_error"></td></tr>  <tr><td><span style="color:red">*</span> Re-enter password:</td><td><input type="password" id="confirm_pw" size="22"                                                                       maxlength="42" /></td></tr>  <tr><td>Location:</td><td><input type="text" id="location" size="22" maxlength="26" />  </td></tr>  <tr><td>Allow emails from admin</td><td align="left"><input type="checkbox" id="allow_admin_email" value="yes" checked="checked" />  </td></tr>  <tr><td colspan="2" id="vcode_error"></td></tr>  <tr><td><?php $user_engine->image_validation();?></td>      <td><input type="text" id="image_code" size="22" maxlength="32" /></td></tr>  <tr>    <td style="margin-top:10px;text-align:left" colspan="2">    <input style="margin-left:35px;" type="submit" value="submit" />    <input type="reset" value="reset" />    <input type="hidden" name="ra" value="true" />    <input type="hidden" name="a" value="9" /></td></tr></table></fieldset></form></div></body></html>