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 7668897
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:28:24+00:00 2026-05-31T15:28:24+00:00

First off my apologies for how disgusting this code is, it is not my

  • 0

First off my apologies for how disgusting this code is, it is not my choice by far, following orders from my boss and others in my team have never done anything web before. Really isn’t good to miss the start of a project!

Basically I want to validate a couple of inputs before progressing to the next page via a submit button. There is no form in use so I am trying to use onClick for the submit button to launch the validate function. Can anybody see what is wrong with the code below (other than it being awful, from the standpoint of getting it to work as wanted.)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- #include file="includes/header.asp" -->
<Center>

<tr>
<td width="100%" height="300" align="center">


    <table width="100%" id="table01">

        <Tr>
            <Td height="30" align="center" colspan="2" style="background-image:url(img/table_header.jpg);background-repeat:repeat-x" >
                <font class="table_header">Password Reset</font>
            </td>
        </tr>
        <tr>
        <Td align="center" height="150" valign="middle">
                <font class="table_grey">
                    Please select one of the methods below to reset your password.
                    <br><br>
                    <form name="radioq"align="center">
                        <input type="radio" name="levels" value="level1" onClick="get_radio_value(1);"/> E-mail a new password<br />
                        <input type="radio" name="levels" value="level2" onClick="get_radio_value(2);"/> Answer secret question<br/>
                    </form>
                        <!-- Javascript to handle which table loads below based on radio selection -->                   
                </font> 
        </td>           
    </tr>

</table>

<table width="100%" class="table01" id="level1" style="display:none;">

        <Tr>
            <Td height="30" align="center" colspan="2" style="background-image:url(img/table_header.jpg);background-repeat:repeat-x" >
                <font class="table_header">E-mail Address</font>
            </td>
        </tr>
        <tr>
        <Td align="center" height="150" valign="middle">
                <font class="table_grey">
                    Please enter your e-mail address and surname.
                    <br/><br/>


                        <font class="table_grey">E-mail Address:&nbsp;</font>

                        <input id="emailinput" size="20" type="text" value="" name="emailinput" />
                        <br/><br/>
                        <font class="table_grey">Surname:&nbsp;</font>

                        <input id="surnameinput" size="20" type="text" value="" name="surnameinput" />
                        <!-- Javascript to handle incorrect surname/email -->                    
                </font>

        </td>
    </tr>

    <tr>                                
        <td align="right">
            <a style="text-decoration:none;"href="password_email_success.asp"><button class="smallbutton" onClick="return validatemail();" type="submit" value="Login" name="submit" class="submit" /><span>Next</span></button></a>
        </td>
    </tr>   
</table>

<table width="100%" class="table01" id="level2" style="display:none;">

        <Tr>
            <Td height="30" align="center" colspan="2" style="background-image:url(img/table_header.jpg);background-repeat:repeat-x" >
                <font class="table_header">Secret Question</font>
            </td>
        </tr>
        <tr>
        <Td align="center" height="150" valign="middle">
                <font class="table_grey">
                    Please answer your secret question below.
                    <br/><br/>


                        <font class="table_grey">What is your mother's maiden name?&nbsp;</font>

                        <br/><br/>
                        <font class="table_grey">Answer:&nbsp;</font>

                        <input id="answerinput" size="20" type="text" value="" name="answerinput" />
                        <!-- Javascript to handle incorrect surname/email -->                    
                </font>

        </td>
    </tr>

    <tr>                                
        <td align="right">
            <a style="text-decoration:none;"href="password_change_success.asp"><button class="smallbutton"  type="submit" value="Login" name="submit" class="submit" /><span>Next</span></button></a>
        </td>
    </tr>   
</table>

<br><br>

<!-- #include file="includes/footer.asp" -->

<script language="Javascript">

function get_radio_value(val)

{

val = val - 1;

for (var i=0; i < document.radioq.levels.length; i++){

      if(i==val){

        document.radioq.levels[i].checked = true;

       }

}

for (var i=0; i < document.radioq.levels.length; i++){

   if (document.radioq.levels[i].checked)

      {

          var rad_val = document.radioq.levels[i].value;

          document.getElementById(rad_val).style.display = "table";

      }

   else{

    var rad_val = document.radioq.levels[i].value;

    document.getElementById(rad_val).style.display = "none";

   }

}

}

function validatemail()
        {
            if ( !isNaN(document.level1.surnameinput.value)  )
            {
                alert("Please enter a valid lastname - text only");
                document.level1.surnameinput.focus();
                return false;
            }
            if ((document.level1.emailinput.value == "") )
            {
                alert("Please enter an email.");
                document.level1.emailinput.focus();
                return false;
            }

            return true;
        }

  • 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-05-31T15:28:25+00:00Added an answer on May 31, 2026 at 3:28 pm

    Call your validatemail() function at the forms onSubmit event instead of one of the buttons onClick event. This is considered best practise as it runs the validation function even when the form is submitted with the ENTER key as well as all related submit buttons.

    <form onSubmit="return validatemail();">
    

    Regadring your submit button, don´t name it “submit” and don´t use the class or any other attributes multiple times on the same element.

    <button type="submit" name="submitButton" value="Login" class="smallbutton" />
    

    Also, all the form elements (input, button etc.) should be placed within the <form></form> tags.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off, please accept my apologies if this question is basic, I mainly have
First off, either A) I'm not investigating into this hard enough or B) I've
First off, apologies if this is a complete noob question which could easily be
First off, I'd like to apologize in advance for not knowing this. I've been
First off - apologies if this or a similar question has been asked before.
First off i'm new to Linux programming so apologies if this makes no sense
First off, apologies if this question has been asked before but I couldn't find
First off - apologies for the poor title, I have no idea how to
(First question related to iPhone development, so apologies for sounding off-track.) I'm creating a
First off, I apologize if this doesn't make sense. I'm new to XHTML, CSS

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.