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

  • Home
  • SEARCH
  • 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 6320589
In Process

The Archive Base Latest Questions

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

<form method=post action=sendmail.php name=Email_form> Message ID <input type=text name=message_id /><br/><br/> Aggressive conduct <input type=radio

  • 0
<form method="post" action="sendmail.php" name="Email_form">
Message ID <input type="text" name="message_id" /><br/><br/>
Aggressive conduct <input type="radio" name="conduct" value="aggressive contact" /><br/><br/>
Offensive conduct <input type="radio" name="conduct" value="offensive conduct" /><br/><br/>
Rasical conduct <input type="radio" name="conduct" value="Rasical conduct" /><br/><br/>
Intimidating conduct <input type="radio" name="conduct" value="intimidating conduct" /><br/><br/>
<input type="submit" name="submit" value="Send Mail" onclick=validate() />
</form>

    window.onload = init;  
    function init()     
    {          
        document.forms["Email_form"].onsubmit = function() 
        {                                                                 
            validate();                                                                 
            return false;                                                             

        };     
    } 

    function validate() 
    {     
        var form = document.forms["Email_form"]; //Try avoiding space in form name.     
        if(form.elements["message_id"].value == "") { //No value in the "message_id" 
            box     
            {         
                alert("Enter Message Id");         
                //Alert is not a very good idea.          
                //You may want to add a span per element for the error message        
                //An div/span at the form level to populate the error message is also ok        
                //Populate this div or span with the error message         
                //document.getElementById("errorDivId").innerHTML = "No message id";

                 return false;  //There is an error. Don't proceed with form submission.

            } 
        }
    }
</script>

Am i missing something or am i just being stupid?

edit***
sorry i should add! the problem is that i want the javascript to stop users going to ‘sendmail.php’ if they have not entered a message id and clicked a radio button… at the moment this does not do this and sends blank emails if nothing is inputted

  • 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-24T16:00:01+00:00Added an answer on May 24, 2026 at 4:00 pm

    You forgot the underscore when identifying the form:

    document.forms["Email_form"].onsubmit = ...
    

    EDIT:

    document.forms["Email_form"].onsubmit = function() {
        return validate();
    };
    
    function validate() {
        var form = document.forms["Email_form"];
        if (form.elements["message_id"].value == "") {
            alert("Enter Message Id");
            return false;
        }
        var conduct = form.elements['conduct']; //Grab radio buttons
        var conductValue; //Store the selected value
        for (var i = 0; i<conduct.length; i++) { //Loop through the list and find selected value
            if(conduct[i].checked) { conductValue = conduct[i].value } //Store it
        }
        if (conductValue == undefined) { //Check to make sure we have a value, otherwise fail and alert the user
            alert("Enter Conduct");
            return false;
        }
        return true;
    }
    

    return the value of validate. Validate should return true if your validation succeeds, and false otherwise. If the onsubmit function returns false, the page won’t change.

    EDIT: Added code to check the radio button. You should consider using a javascript framework to make your life easier. Also, you should remove the onclick attribute from your submit input button as validation should be handled in the submit even, not the button’s click

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

Sidebar

Related Questions

I have a form <form method=post action=sendmail.php name=Email form> Message ID <input type=text name=message_id
I have an HTML form: <form action='process.php' method='post'> <input type='checkbox' name='check_box_1' /> Check me!<br>
I have a simple form like this: <form name=serachForm method=post action=/home/search> <input type=text name=searchText
HTML <form id=contact_form action=# name= method=POST> <label for=name>NAME</label> <input type=text name=name id=name class=contact_form_input />
<form id='new_key' action='/foo/bar' method='post'> <input type=text id=u> <input type=submit value=submit> </form> I can bind
<form method = post action = <?php echo $_SERVER['PHP_SELF']; ?> /> Username:<input type =
Getting variable from form: <form method = 'POST' action = ''> <input type =
I'm using a form containing a button type shown below: <form method=post action=> <button
<form action=/Villa/Add method=post> <table> <tr> <td> Name: </td> <td> <%= Html.TextBox(name) %> <%= Html.ValidationMessage(Name)
Imagine this simple form <form action=<?php echo $_SERVER['REQUEST_URI']; ?> method=post> <fieldset> <legend>Contact Me</legend> <label

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.