Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Simple Text Variable Error

    I am attempting to actively add multiple lines of text to the bottom of the page based on if conditions. However I am having trouble with breaking each message into its own line, making the text red and bold, and having the text blink if possible. After reading some info online I thought I had the problem fixed, however instead I see the following in the browser:

    <FONT COLOR="FF0000"><B>Password Must Contain Two Upper Case Letters.<br></B></FONT>

    when I use this code snippet:
    else { // adds warning text
    var p3 = document.getElementsByTagName('upperCaseLetter')[0];
    if (newPassword != 0 && p3 == null){ //only adds warning if a password is present and no warning message exists
    var newPUpper = document.createElement("upperCaseLetter");
    var txtUpper = "Password Must Contain Two Upper Case Letters." + "<br>";
    txtUpper = txtUpper.bold().fontcolor("FF0000");
    var newTUpper = document.createTextNode(txtUpper);
    newPUpper.appendChild(newTUpper);
    var theBody = document.getElementsByTagName('body')[0];
    theBody.appendChild(newPUpper);
    }//end of if statment

    Any help is much appreciated!

  • #2
    New to the CF scene
    Join Date
    Aug 2008
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    I have updated my function to fix some of my previous problems. The idea is that when a user is actively typing in a password, it checks the complexity and updates which requirements are not meet. I have added the entire function responsible for this below. I did try using this:

    var myUpperBreak=document.createElement("br");
    theBody.appendChild(newPUpper);
    theBody.appendChild(myUpperBreak);

    and it worked however, each time a message would reappear, it would lower on the page. Here is my entire function:

    function testPassword (newPassword) {

    if (newPassword.match(/([a-z].*[a-z])/)) // checks for two lower case letters
    {
    var p2 = document.getElementById('lowerCaseLetter');
    if (p2 != null){ //checks to see if there already exists warning text and removes it
    p2.parentNode.removeChild(p2);
    }//end of if statement
    }//end of if statement
    else { // adds warning text
    var p2 = document.getElementById('lowerCaseLetter');
    if (newPassword != 0 && !p2){ //only adds warning if a password is present and no warning message exists
    var newPLower = document.createElement('span');
    newPLower.id = 'lowerCaseLetter';
    var txtLower = 'Password Must Contain Two Lower Case Letters.';
    newPLower.style.fontWeight = 'bold';
    newPLower.style.color = 'blue';
    newPLower.appendChild(document.createTextNode(txtL ower));
    document.body.appendChild(newPLower);
    }//end of if statment
    else {//removes warning message if password is not entered and warning message exsists
    if (newPassword == 0 && p2 != null){
    p2.parentNode.removeChild(p2);
    }//end of if statement
    }//end of else statement
    }// end of else statement

    if (newPassword.match(/([A-Z].*[A-Z])/)) // checks for two upper case letters
    {
    var p3 = document.getElementById('upperCaseLetter');
    if (p3 != null){ //checks to see if there already exists warning text and removes it
    p3.parentNode.removeChild(p3);
    }//end of if statement
    }//end of if statement
    else { // adds warning text
    var p3 = document.getElementById('upperCaseLetter');
    if (newPassword != 0 && !p3){ //only adds warning if a password is present and no warning message exists
    var newPUpper = document.createElement('span');
    newPUpper.id = 'upperCaseLetter';
    var txtUpper = "Password Must Contain Two Upper Case Letters.";
    newPUpper.style.fontWeight = 'bold';
    newPUpper.style.color = 'red';
    newPUpper.appendChild(document.createTextNode(txtU pper));
    document.body.appendChild(newPUpper);
    }//end of if statment
    else {//removes warning message if password is not entered and warning message exsists
    if (newPassword == 0 && p3 != null){
    p3.parentNode.removeChild(p3);
    }//end of if statement
    }//end of else statement
    }// end of else statement

    }//end of function testPassword


  •  

    Posting Permissions

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