SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    javascript validation error

    this is how i call the editor:

    Code:
    	<!-- editor -->
    	<? include "js/editor/buttons.php"; ?>
    	<iframe id="textbox" class="Eddietor" src="js/editor/editor.php"></iframe><br />
    	<input type="hidden" id="content" name="content">
    	<!-- /editor -->
    and this is editor.js:

    Code:
    window.onload = function()
    {
    	Editor = document.getElementById('textbox').contentWindow.document;
    	Editor.designMode = "on";
    	document.forms[0].onsubmit = function()
    	{
    		var text = document.getElementById('text');
    		text.value = Editor.body.innerHTML;
    	}
    }
    
    function doColor(colour)
    {
    	document.getElementById("textbox").contentWindow.focus();
    	document.getElementById("textbox").contentWindow.document.execCommand("forecolor",false, colour);
    }
    
    
    
    function doClick(command) {
    document.getElementById("textbox").contentWindow.focus();
    document.getElementById("textbox").contentWindow.document.execCommand(command, false, null);
    }
    function doLink() {
    var mylink = prompt("URL:", "http://");
    if ((mylink != null) && (mylink != "")) {
    document.getElementById("textbox").contentWindow.focus();
    document.getElementById('textbox').contentWindow.document.execCommand("CreateLink",false,mylink);
    }
    }
    function doImage() {
    myimg = prompt('URL:', 'http://');
    document.getElementById("textbox").contentWindow.focus();
    document.getElementById('textbox').contentWindow.document.execCommand("InsertImage", false, myimg);
    }
    another script i made is having problems with the ID="textbox" , it might be fixed if i change id and start using name="textbox" instead,
    but i don't know how to do this in js. need to edit the editor.js and change id="textbox"->to->name="textbox"
    can anyone help me? i got no idea how to use the getElementByName thingie , i'm trying to do this for 4 hours already and still no go.

    appreciated.

  2. #2
    One website at a time mmj's Avatar
    Join Date
    Feb 2001
    Location
    Melbourne Australia
    Posts
    6,282
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    <quote>another script i made is having problems with the ID="textbox" </quote>

    What problems? What part of the other script is causing the problem?

    It sounds like the other script is broken and that's what you need to fix.
    [mmj] My magic jigsaw
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    The Bit Depth Blog Twitter Contact me
    Neon Javascript Framework Jokes Android stuff

  3. #3
    SitePoint Member
    Join Date
    Aug 2011
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mmj View Post
    <quote>another script i made is having problems with the ID="textbox" </quote>

    What problems? What part of the other script is causing the problem?

    It sounds like the other script is broken and that's what you need to fix.
    HTML Code:
    function validateEmpty(fld) {
        if (fld.value.length == 0) {
            fld.style.background = '#FFB2B2';
            error = "The required field has not been filled in.\n"
        } else {
            fld.style.background = 'White';
        }
        return error;  
    }
    
    // ******************
    // USERS
    // ******************
    function validateForm_users(theForm) {
    var reason = "";
    	reason += validateEmpty(theForm.username);	
    	reason += validateEmpty(theForm.db_name);
    	reason += validateEmpty(theForm.db_user);
    	reason += validateEmpty(theForm.db_pass);
      if (reason != "") {
        alert("EMPTY PLEASE TRY AGAIN");
        return false;
      }
      return true;
    }
    
    
    // ******************
    // PAGES
    // ******************
    function validateForm_pages(theForm) {
    var reason = "";
    	reason += validateEmpty(theForm.title);
    	reason += validateEmpty(theForm.name);
      if (reason != "") {
        alert("EMPTY PLEASE TRY AGAIN");
        return false;
      }
    
    }
    this is the script for validating empty forms
    maybe it is broken? can you tell me if you see any errors in it

  4. #4
    SitePoint Enthusiast
    Join Date
    Jul 2011
    Location
    South Africa
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HTML DOM Document getElementsByName() Method
    this should help you with
    i got no idea how to use the getElementByName thingie


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •