Jump to content

Stickybomb

Members
  • Posts

    133
  • Joined

  • Last visited

    Never

Posts posted by Stickybomb

  1. hmm first i noticed i had a variable issue in the length function i fixed that with no effect, then i tried implementing the global like you suggested but then it did not even display check mark.  ???

     

    the problem doe snot seem to be with the validation functions or the array. i hardcoded a value and still recieved the check marks, which mean the error is some where in the checking or list functions

  2. ok i managed to make a little head room I reworked the script a little. I managed to get it to acctually display a response. I seems however either the validation functions are not working properly or at all since no matter what i input into the fields it returns a check mark symbolizing that there were no errors. It may also be that they are working fine and my checking for errors may be causeing a problem, but I can not seem to see the problem myself.

     

    here is the php code

    <?php
    $data = $_GET['data'];
    
    $errors;
    
    //is alphanumeric
    function isAlphaNum($input) {
    	if(!eregi("^([0-9a-zA-Z])*$", $input)){
    		$errors[]='* must only contain alphanumeric characters';
    	}			
    }
    
    //check if length
    function checkLength($input,$max,$min) {
    	if($data=='' || strlen(trim($data)) < $min){
    		$errors[]='* must be at least '.$min.' characters';
    	}
    
    	if($data=='' || strlen(trim($input)) > $max){
    		$errors[]='* must can not exceed '.$max.' characters';
    	}
    }
    
    //check for errors
    function isErrors() {
    	if (isset($errors) && count($errors) > 0){
    		return true;
    	}else{
    		return false;
    	}
    }
    
    //list errors
    function listErrors($delim = ' '){
    	if (isset($errors) && count($errors) > 0){
    		return implode($delim,$errors);
    	}
    }
    
    switch($_GET['field']){
    
    	case'userid':
    
    		checkLength($data,3,255);
    		isAlphaNum($data);
    
    		if(isErrors()){
    ?>
    <!--passes errors for display as well as showing a red x symbolizing an error-->
    <script type="text/javascript">
    	window.addEvent('domready', function(){
    		$('iconuserid').setStyle('background-position','0 50%');
    		$('erruserid').setStyle('visibility','visible').empty().appendText(<?=listErrors();?>);
            });
    </script>
    <?php
    		}else{
    ?>
    <!--displays a green check symbolizing no errors-->
    <script type="text/javascript">
    	window.addEvent('domready', function(){
    		$('iconuserid').setStyle('background-position','0 0');
    		$('erruserid').setStyle('visibility','hidden').empty();
            });
    </script>
    <?php
    		}
    
    	break;
    
    	case'pass':
    
    
    		checkLength($data,6,16);
    		isAlphaNum($data);
    
    		if(isErrors()){
    ?>
    <!--passes errors for display as well as showing a red x symbolizing an error-->
    <script type="text/javascript">
    	window.addEvent('domready', function(){
    		$('iconpass').setStyle('background-position','0 50%');
    		$('errpass').setStyle('visibility','visible').empty().appendText(<?=listErrors();?>);
            });
    </script>
    <?php
    		}else{
    ?>
    <!--displays a green check symbolizing no errors-->
    <script type="text/javascript">
    	window.addEvent('domready', function(){
    		$('iconpass').setStyle('background-position','0 0');
    		$('errpass').setStyle('visibility','hidden').empty();
            });
    </script>
    <?php
    		}
    
    	break;
    }
    ?>
    

     

    this is the page running it

    new version

     

  3. firstly its not a download i changed the file to .phps which means you view the code in your browser rather than posting it here its easier to read and faster then copy and paste.

     

    second I provided a link to a page with it working and a page with it not. I am not sure of the problem or i could fix it myself. So its kind of difficult to give you more information, how about

     

    'nothing happens' the ajax response is either not getting recieved or its not getting what its intended to get. There are no errors displayed!

     

    it is designed to validate each field after they loose focus, try clicking in the fields on both examples. The js code is identicall I only changed the php so it has to be a hp problem

  4. I am attempteing to modify the login I found at roscripts.com to accomodate my needs.

     

    I got it to work fine by validating individually for each error and displaying a message.

     

    the mootools and the javascript are working fine, I am having issues with my php code.

     

    I would like to simplify and streamline the process so I put all the validations in functions and am adding the error messages to an array.

     

    I then test if it has any errors and list them if any are present, but for some reason It does not function.

     

    I am trying to implement this into a class I am working on so any help is appriciated

     

    working version <- very clutered and not practical

    php file

     

    new version <- not cluttered and more streamlined, easier to update

    php file

     

     

  5. this can also be accomplished via ajax or a number of ways via js.

     

    however you will have better seo via the use of an iframe, but if this is little concern to you then try this.

     

    the scroll bar is simply a div with an overflow:scoll style applied

     

    then for the tabs each one would have an onclick="pageContent(this)" event changing its background color and switching the contents of the div.

     

    first create an html file for each of the tabs and lay them out appropriately.

     

    then you need the following js

     

    var xmlHttp;
    
    //contains all the tabs ids
    var tabs = array('tab1','tab2','tab3');
    
    function pageContent(tab){
    
    var currentTab = document.getElementById(tab);
    
    for(i=0; i < tabs.length; i++){
    var clear = document.getElementById(tabs[i]);
    clear.style.backgroundColor='default tab background color';
    clear.style.color='default color of font';
    }
    
    var currentTab = document.getElementById(tab);
    
    currentTab.style.backgroundColor='current tab background color';
    currentTab.style.color='color of font';
    
    getContent(tab);
    }
    
    function getContent(page){ 
    xmlHttp=GetXmlHttpObject()
    if (xmlHttp==null)
    {
    alert ("Browser does not support HTTP Request")
    return
    } 
    var url = page+'.html';
    xmlHttp.onreadystatechange=stateChanged 
    xmlHttp.open("GET",url,true)
    xmlHttp.send(null)
    }
    
    function stateChanged() 
    { 
    if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
    {
    document.getElementById("the id of the content div").innerHTML=xmlHttp.responseText ;
    } 
    }
    
    function GetXmlHttpObject()
    {
    var xmlHttp=null;
    try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
    catch (e)
    {
    //Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    }
    return xmlHttp;
    }
    

     

    i have not tested this but it should work for you.

  6. wow ok there alot of problems here.

     

    first you need to use the getElementById method to aquire something instead of just the id value.

     

    also that is a hugh conditonal which would take along time to run through for each field.

     

    chanceis are you are caught in an infinte loop or timing out.

     

    here try this i use it with some of my forms

     

    /*
    	Required field(s) validation- By NavSurf
    	Visit NavSurf.com at http://navsurf.com
    	Visit http://www.dynamicdrive.com for this script
    	*/
    
    	function formCheck(formobj){
    		//1) Enter name of mandatory fields
    		var fieldRequired = Array("firstname", "lastname", "company", "address", "city", "StateorProvince", "postalcode", "country", "phone");
    		//2) Enter field description to appear in the dialog box
    		var fieldDescription = Array("First Name", "Last Name", "Company", "Address", "City", "State/Providence", "Postal Code", "Country", "Phone");
    		//3) Enter dialog message
    		var alertMsg = "Please complete the following fields:\n";
    
    		var l_Msg = alertMsg.length;
    
    		for (var i = 0; i < fieldRequired.length; i++){
    			var obj = formobj.elements[fieldRequired[i]];
    			if (obj){
    				switch(obj.type){
    					case "select-one":
    					if (obj.selectedIndex == -1 || obj.options[obj.selectedIndex].text == ""){
    						alertMsg += " - " + fieldDescription[i] + "\n";
    					}
    					break;
    					case "select-multiple":
    					if (obj.selectedIndex == -1){
    						alertMsg += " - " + fieldDescription[i] + "\n";
    					}
    					break;
    					case "text":
    					case "textarea":
    					if (obj.value == "" || obj.value == null){
    						alertMsg += " - " + fieldDescription[i] + "\n";
    					}
    					break;
    					default:
    					if (obj.value == "" || obj.value == null){
    						alertMsg += " - " + fieldDescription[i] + "\n";
    					}
    				}
    			}
    		}
    
    		if (alertMsg.length == l_Msg){
    			return true;
    		}else{
    			alert(alertMsg);
    			return false;
    		}
    	}
    

     

    all you need to do is alter the required fields array and the description array to suit your form.

  7. ??? sounds like its not creating the xml object for some reason.

    however i understand little to nothing about what you are trying to do.

     

    so you have two drop menus with one controlling the content of the other?

     

    the way its worded it sounds like you want to change the contents of the selecet menu onchange which makes nosense and would serve no logical reason.

     

    can you provide a link to what you are attempting to do.

  8. ok so & is basically like saying that no matter where the varible is updated give it the most recent value

     

    so for instance

     

    $bar = 6

    $foo = $bar

    $bar = 12

     

    print $foo // 6

     

    $bar = 6

    $foo = &$bar

    $bar = 12

     

    print $foo // 12

     

     

     

    if this is correct, then is this affected by scope? or is it referenced by document

  9. hi i am currently trying to laern more about php witch inlcudes trying to work with its oop form. I have come across a few instances where there have been either variables,functiions or methods prepended with either the @ or &.

     

    can anyone explain these uses for example

     

    i seen something like this

     

    @mail ($variable,$variable,$variable)

     

    and i have seen this

     

    function showBox(&$connector){

        //do something

     

      return result

    }

     

    what are the meanings of these and the specific uses please

  10. hi i am working on a project. it is going to be a rather large site and we are looking into controling the page content through ajax. so baically there will be one page and the content will be created through an ajax call to a seperate file. for each link clicked.

     

    My question is how would this affect search engines, what are the down sides and upsides.

  11. so you just want to display a popup with out using a window?

     

    you can do this with ajax. its not to hard. there are also several frameworks that offer this ability.

     

    just search for ajax widows or popus should be alot of tutorials on it

  12. instead of using window.location you can write a meta redirect

     

    document.write("<meta http-equiv='refresh' content='5;url=http:www.yoursite.com' />");

     

    as long as this is run in the head it should work fine.

     

    however if you are want to work with cookies i would suggest using php its alot simpler to use and work with cookies

  13. firstly you are using an ajax request. you y r u encode anything in js you are communicateing soely on your server, just clean and check the posted information in the php file. As far as I know the user has no access to a request from your server to your server? And as long as you are using post the user has not access to it if it was not sent by your server post is a secure method, get on the other hand can be vulnerable since it appends data to the url.

  14. well how about posting your code and corresponding html...

     

    first i would seriously look into resarching event listners inline js is something you should try and avoid at all costs.

     

    basically though all you need to do is change the style.display value from block to none and vice-verse, but like i said maybe you aready no that but i cant' tell from the lack of code provided lol.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.