Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T03:56:48+00:00 2026-06-07T03:56:48+00:00

I am trying to construct a registration form using the code below, I am

  • 0

I am trying to construct a registration form using the code below, I am still in the beginning phase. I am having a really difficult time executing any of the JavaScript code that is within the PHP echo statement.

I tried escaping the single and double quotes within the javascript functions using the slash \' and \", which worked for the top javascript function, but once I added the other two functions and applied the same logic, all javascript functions stopped working.

Can someone please advise what is the easiest way to prevent problems and easily execute javascript code that is within a php echo statement?

<?php

echo '
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>      
    <script type="text/javascript">
        function validateEmail(email) { 

            var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;

            if(re.test(email)) {
                document.getElementById(\'result\').innerHTML = \'<img src=\"http://www.customotion.com/green_check_small.png\" style=\"width:15px;\"/> Valid\';
            } else {
                document.getElementById(\'result\').innerHTML = \'<img src=\"http://biglistbigsales.com/m/templates/GPT/images/x_xMarkRed4.png\" style=\"width:15px;\"/> Invalid\';
            }
        }   

    </script>
</head>

<body>
<div id="main-container">

<div id="body-container" style="padding-bottom:150px; height:800px;">
    <div style="height:100px; margin:0px auto;">
        <img class="reg-step" style="width:100%;" src="images/step1.png">
    </div>
    <div style="margin-left:110px;">
        <span style="font-size:24px;" class="smallheading">Tell Us About Yourself</span>
        <br/><span style="font-size:13.5px;"><i>*All fields required</i></span>
    </div>

    <form method="post" action="registernew.php">
    <div style="margin:0px auto; margin-left:110px; border:1px solid blue; float:left; font-size:12px; width:500px;">
        <div style="border:1px solid blue; float:left; width:80%;">
            <div style="float:left; border:1px solid red;">
                First Name:
                <br/><input type="text" style="width:140px;" name="fname" />
            </div>

            <div style="float:right; margin-right:50px; border:1px solid red;">
                Last Name:
                <br/><input type="text" style="width:140px;" name="lname" />
            </div>
        </div>

        <div style="border:1px solid blue; float:left; margin-top:20px; width:50%;">
            <div style="float:left; border:1px solid red;">
                City:
                <br/><input type="text" style="width:170px;" name="fname" />
            </div>
            <div style="float:right; border:1px solid red;">
                State:
                <br/>';
                include('inc/statedropdown.inc.php');
echo'       </div>
        </div>
        <div style="float:left; width:100%;">
            <br/>Company Name:<br/> <input type="text" name="fname" style="width:150px;"/>
            <br/><br/>E-mail Address:<br/> e-mail:<br/><input id="email" type="text" onblur="validateEmail(this.value)" /><span id="result"></span>
            <br/><br/>Phone Number:<br/> <input type="text" name="fname" style="width:110px;" />
            <br/><br/>Password:<br/><input type="password" name="fname" />
            <br/><br/>Confirm Password:<br/><input type="password"  name="lname" />

            <br/><input type="submit" value="Next Step" style="background-color:#ebda5f; color:blue; margin:15px 0px 0px 20px;">
        </div>
    </form>
    </div>
</div>
</div>
</body>
</html>';

?>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T03:56:49+00:00Added an answer on June 7, 2026 at 3:56 am

    Only use the <?php ?> tags when they’re needed. Anything not inside the tags gets echoed and treated like HTML.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>      
        <script type="text/javascript">
            function validateEmail(email) { 
    
                var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
    
                if(re.test(email)) {
                    document.getElementById(\'result\').innerHTML = \'<img src=\"http://www.customotion.com/green_check_small.png\" style=\"width:15px;\"/> Valid\';
                } else {
                    document.getElementById(\'result\').innerHTML = \'<img src=\"http://biglistbigsales.com/m/templates/GPT/images/x_xMarkRed4.png\" style=\"width:15px;\"/> Invalid\';
                }
            }   
    
        </script>
    </head>
    
    <body>
    <div id="main-container">
    
    <div id="body-container" style="padding-bottom:150px; height:800px;">
        <div style="height:100px; margin:0px auto;">
            <img class="reg-step" style="width:100%;" src="images/step1.png">
        </div>
        <div style="margin-left:110px;">
            <span style="font-size:24px;" class="smallheading">Tell Us About Yourself</span>
            <br/><span style="font-size:13.5px;"><i>*All fields required</i></span>
        </div>
    
        <form method="post" action="registernew.php">
        <div style="margin:0px auto; margin-left:110px; border:1px solid blue; float:left; font-size:12px; width:500px;">
            <div style="border:1px solid blue; float:left; width:80%;">
                <div style="float:left; border:1px solid red;">
                    First Name:
                    <br/><input type="text" style="width:140px;" name="fname" />
                </div>
    
                <div style="float:right; margin-right:50px; border:1px solid red;">
                    Last Name:
                    <br/><input type="text" style="width:140px;" name="lname" />
                </div>
            </div>
    
            <div style="border:1px solid blue; float:left; margin-top:20px; width:50%;">
                <div style="float:left; border:1px solid red;">
                    City:
                    <br/><input type="text" style="width:170px;" name="fname" />
                </div>
                <div style="float:right; border:1px solid red;">
                    State:
                    <br/>
                    <?php include('inc/statedropdown.inc.php'); ?>
                </div>
            </div>
            <div style="float:left; width:100%;">
                <br/>Company Name:<br/> <input type="text" name="fname" style="width:150px;"/>
                <br/><br/>E-mail Address:<br/> e-mail:<br/><input id="email" type="text" onblur="validateEmail(this.value)" /><span id="result"></span>
                <br/><br/>Phone Number:<br/> <input type="text" name="fname" style="width:110px;" />
                <br/><br/>Password:<br/><input type="password" name="fname" />
                <br/><br/>Confirm Password:<br/><input type="password"  name="lname" />
    
                <br/><input type="submit" value="Next Step" style="background-color:#ebda5f; color:blue; margin:15px 0px 0px 20px;">
            </div>
        </form>
        </div>
    </div>
    </div>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to design a user registration form using code igniter 2.1.0. I
I am trying to construct a TreeView from a Menu. My Code is like
I'm trying to construct a 2D array in the form of pointers-to-pointers. This doesn't
I am presently trying to construct an OBB (Oriented Bounding Box) using the source
I am trying to construct a DateTime in C# one step at a time,
I'm trying to construct a path using a command-line argument in bash. I added
Trying to construct a Request with Network.HTTP.Conduit package. The instructions are: The constructor for
Am trying to construct a simple update query in my model class Model_DbTable_Account extends
I am trying to construct a customized map in raphaeljs , in this i
I am trying to construct a deeply nested associative array but i don't know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.