easy and quick Simple form edit please - html

The forms which l have here, have required files to be entered before the submit button. All l need it for the top 'title' list to be required='true'. I know how to do it for each and every of the text forms but unsure how to position the code for an options choice list.
Cheers guys.
Please take a look at the jsfiddle l have created for this:
http://jsfiddle.net/New_to_Websites/5A4vS/#run
Code:
<script language="javascript">
var sa_sent_text = 'Thank you for contacting us. We will get back to you soon.';
function sendme() {
alert(sa_sent_text);
document.getElementById("name").value = "";
document.getElementById("message").value = "";
document.getElementById("subject").value = "";
document.getElementById("email").value = "";
return false;
}
</script>
<div id="sa_contactdiv">
<form name=sa_htmlform style="margin:0px" onsubmit="return sendme();">
<table>
<tr>
<td>Title:
<br>
<select name="title" size="1">
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss">Miss</option>
<option value="Ms.">Ms.</option>
<option value="Dr.">Dr.</option>
<option value="Prof.">Prof.</option>
<option value="Other">Other</option>
</select>
</td>
</tr>
<tr>
<td>Name:
<br>
<input type="text" id="name" name="name" />
</td>
</tr>
<tr>
<td>E-mail Address: <span style="color:#D70000">*</span>
<br>
<input type="text" id="email" name="email" required="true" />
</td>
</tr>
<tr>
<td>Subject: <span style="color:#D70000">*</span>
<br>
<input type="text" id="subject" name="subject" required="true" />
</td>
</tr>
<tr>
<td>Message: <span style="color:#D70000">*</span>
<br>
<textarea name="message" id="message" cols="42" rows="9" required="true"> </textarea>
</td>
</tr>
<tr>
<td>
<input type="submit" value="Send Message" style="font-weight:bold">
</td>
</tr>
</table>
</form>
</div>

This should work:
<select name="title" size="1" required aria-required=”true”>
<option value="">Please Choose</option>
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss">Miss</option>
<option value="Ms.">Ms.</option>
<option value="Dr.">Dr.</option>
<option value="Prof.">Prof.</option>
<option value="Other">Other</option>
</select>
If you have an option with a empty value as default, the required attribute works.
Working Fiddle
The required attribute is a boolean attribute. When specified, the user will be required to select a value before submitting the form.
If a select element has a required attribute specified, does not have a multiple attribute specified, and has a display size of 1; and if the value of the first option element in the select element's list of options (if any) is the empty string, and that option element's parent node is the select element (and not an optgroup element), then that option is the select element's placeholder label option.
Quoted from http://dev.w3.org/html5/spec-author-view/the-select-element.html

Try this
<td>Title:<span style="color:#D70000">*</span>
<br>
<select name="title" size="1" required="true">
<option value=""></option>
<option value="Mr.">Mr.</option>
<option value="Mrs.">Mrs.</option>
<option value="Miss">Miss</option>
<option value="Ms.">Ms.</option>
<option value="Dr.">Dr.</option>
<option value="Prof.">Prof.</option>
<option value="Other">Other</option>
</select>

Related

Line Break After Dropdown in HTML

I am trying to add a submit button after a dropdown list in an HTML form. I am unable to add a line break between the dropdown list and submit button. Attached is a Picture of the form. Below is the code I am using. Any help would be greatly appreciated.
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<form>
<div>
<input required type="text" name="firstname" placeholder="First Name"><br>
<br><input required type="text" name="lastname" placeholder="Last Name"><br>
<br><input requiredtype="email" name="email" placeholder="Email"><br>
<br><input required type="text" name="phonenumber" placeholder="Phone Number"><br>
<br><input required type="text" name="handicap" placeholder="Handicap"><br>
<br><select required name="shirtsize" size = 1>
<option value="" selected>Shirt Size</option>
<option value="S"> S </option>
<option value="M"> M </option>
<option value="L"> L </option>
<option value="XL"> XL </option>
<option value="XXL"> XXL </option>
<option value="XXXL"> XXXL </option>
<input type="submit" value=Register>
</div>
</form>
</body>
</html>
Close the select and add a line break (<br>)
<select required name="shirtsize" size = 1>
<option value="" selected>Shirt Size</option>
<option value="S"> S </option>
<option value="M"> M </option>
<option value="L"> L </option>
<option value="XL"> XL </option>
<option value="XXL"> XXL </option>
<option value="XXXL"> XXXL </option>
</select>
<br>
<input type="submit" value=Register>
#David is exactly right, I'd add a second line break though to keep the format similar to your picture.
<select required name="shirtsize" size = 1>
<option value="" selected>Shirt Size</option>
<option value="S"> S </option>
<option value="M"> M </option>
<option value="L"> L </option>
<option value="XL"> XL </option>
<option value="XXL"> XXL </option>
<option value="XXXL"> XXXL </option>
</select>
<br>
<br>
<input type="submit" value=Register>

HTML: how to show a form input in a table?

I am new to HTML and I am wondering how do I convert the form inputs into a table?
I created a display button, so that when I click on it, the information submitted by a user will be displayed in a table.
<html>
<style>
</style>
<body>
<p> Please insert the following information for your Gym Membership.</p>
<form>
<br>
<label for="name">Name:</label>
<input type="text" id="name">
<br><br>
<label for="age">Age (between 18-60):</label>
<input type="number" id="age" min="18" max="60"><br><br>
<label for="cars">Select your height (feet and inches):</label>
<select id="feet">
<option value="4">4'</option>
<option value="5">5'</option>
<option value="6">6'</option>
</select>
<select id="inches">
<option value="1">1"</option>
<option value="2">2"</option>
<option value="3">3"</option>
<option value="4">4"</option>
<option value="5">5"</option>
<option value="6">6"</option>
<option value="7">7"</option>
<option value="8">8"</option>
<option value="9">9"</option>
<option value="10">10"</option>
<option value="11">11"</option>
</select>
<br>
<br>
<input type="reset" value="Reset">
<input type="submit" value="Display">
</form>
</body>
</html>
It's mandatory to add some javascript to it.
Since you're new to HTML/javascript, I modified your snippet of code to meet your needs.
HTML :
<html>
<style>
</style>
<b>
<p> Please insert the following information for your Gym Membership.</p>
<form action="#" method="post" name="form_name" id="form_id" class="form_class" >
<br>
<label for="name">Name:</label>
<input type="text" id="name">
<br><br>
<label for="age">Age (between 18-60):</label>
<input type="number" id="age" min="18" max="60"><br><br>
<label for="cars">Select your height (feet and inches):</label>
<select id="feet">
<option value="4">4'</option>
<option value="5">5'</option>
<option value="6">6'</option>
</select>
<select id="inches">
<option value="1">1"</option>
<option value="2">2"</option>
<option value="3">3"</option>
<option value="4">4"</option>
<option value="5">5"</option>
<option value="6">6"</option>
<option value="7">7"</option>
<option value="8">8"</option>
<option value="9">9"</option>
<option value="10">10"</option>
<option value="11">11"</option>
</select>
<br>
<br>
<input type="reset" value="Reset">
<input type="button" Value="submit" onclick="Display()">
</form>
</b>
</html>
<div id="table" style="display:none;" class="answer_list" > <table id="myTable">
</table></div>
Javascript :
function Display()
{
document.getElementById('table').style.display = "block";
var table = document.getElementById("myTable");
var row = table.insertRow(0);
var cell1 = row.insertCell(0);
var cell2 = row.insertCell(1);
var cell3 = row.insertCell(2);
cell1.innerHTML = document.getElementById("name").value;
cell2.innerHTML = document.getElementById("age").value;
cell3.innerHTML = document.getElementById("feet").value+"," +document.getElementById("inches").value;
}
or you can find it in the link below, it works fine :
https://codepen.io/iliass-coder/pen/jOPBbdz
Take some time to read it and understand what I did. and try to add some CSS, it's a bit ugly for the moment.

Form Validation not working with tel, email and select

I use Dreamweaver to write my html code, but now have run into a problem.
I have created an enquiry form which contains several different fields, but when I try to validate the form using Window | Behavior | Validate Form, it only shows my "firstname", "lastname", "Datepicker1", "Datepicker2" as well as the "Comments" field.
I want to make sure that the telephone, email and select fields are required and will be filled by a number and an email address. It worked fine when I made the contact form, but for some reason it does not in the enquiry.
My code is as follows:
<form action="../../enquiryform.php" method="post" id="enquiry">
<h1>ENQUIRE ABOUT<br><span style="color:#816122">VILLA 2610</span></h1>
<input type="hidden" name="villaid" id="villaid" value="2610">
<br>
Arrival Date<br>
<input type="text" name="arrivaldate" id="Datepicker1">
<br>Departure Date<br>
<input type="text" name="departuredate" id="Datepicker2"><br>
First Name
<input type="text" name="firstname" id="firstname"><br>
Last Name
<input type="text" name="lastname" id="lastname"><br>
Telephone
<input type="tel" name="tel" id="tel"><br>
Email
<input type="email" name="email" id="email"><br>
<div class="leftcolumn">Adults<br>
<select name="adults" id="adults">
<option value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select>
</div>
<div class="rightcolumn">Children<br>
<select name="children" id="children">
<option value=""> </option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10+">10+</option>
</select>
</div>
Comments (optional)<br>
<textarea name="comments" id="comments" wrap="soft" style="width:150px; height:100px;"></textarea><br>
<p class="antispam">Leave this empty: <input name="url" type="text" id="url" /></p>
<input type="submit" value="Send" style="background-color:#aa802c; color:#FFFFFF; border-radius:5px; text-align:center; cursor:pointer;"><br><br>
I have added the following inside the starting form bracket:
onSubmit="MM_validateForm('firstname','','R','lastname','','R');return document.MM_returnValue"
But what should I use for a telephone number, email address as well as the 2 select options that I have?
My suggestion is
onSubmit="MM_validateForm('firstname','','R','lastname','','R','tel','','RisNum','email','','RisEmail',);return document.MM_returnValue"
But how do I add that I require for my viewers to select children and adults options?
And are my thoughts above correct?
Why don't you use the require attribute on input tag like this
Telephone
<input type="tel" name="tel" id="tel" required>

How to make all output in a one line using html?

<html>
<body>
<form name="orderform" action="order.php" method="POST">
<label>Username</label><br>
<input name="user" type="text" value="" size="10" maxlength="22">
<br>
<label>Items</label>
<div align="left">
<select name="mydropdown">
<option value="macbook">Macbook</option>
<option value="sony">Sony</option>
<option value="micromax">Micromax</option>
<option value="napolean">Napolean</option>
<option value="motorola">Motorola</option>
</select>
</div>
<label>Quantity</label>
<div align="left">
<select name="mydropdown">
<option value="quantity1">1</option>
<option value="quantity2">2</option>
<option value="quantity3">3</option>
<option value="quantity4">4</option>
<option value="quantity5">5</option>
</select>
</div>
<input name="Order" type="submit" value="Order">
</form>
<form name="orderform" action="addtocart.php" method="POST">
<input name="Cart" type="submit" value="Add to Cart">
</form>
</body>
</html>
after executing this code all output is in vertical form i just wanted to make it in a line.please give me a solution i am new in php.
Try this
<!doctype html>
<html>
<head>
<style type="text/css" media="screen">
form div {
display: inline-block;
}
</style>
</head>
<body>
<form name="orderform" action="order.php" method="POST">
<div>
<label>Username</label>
<input name="user" type="text" value="" size="10" maxlength="22">
</div>
<div align="left">
<label>Items</label>
<select name="mydropdown">
<option value="macbook">Macbook</option>
<option value="sony">Sony</option>
<option value="micromax">Micromax</option>
<option value="napolean">Napolean</option>
<option value="motorola">Motorola</option>
</select>
</div>
<div align="left">
<label>Quantity</label>
<select name="mydropdown">
<option value="quantity1">1</option>
<option value="quantity2">2</option>
<option value="quantity3">3</option>
<option value="quantity4">4</option>
<option value="quantity5">5</option>
</select>
</div>
<div>
<input name="Order" type="submit" value="Order">
</div>
<div>
<input name="Cart" type="submit" value="Add to Cart">
</div>
</form>
</body>
</html>
It would be easy to put it all on one line using CSS. You would just remove the default line breaking effects of some elements:
form, form div { display: inline }
form br { display: none }
To do the same in HTML requires modification of the HTML markup, of course. You just remove the div and br tags, but the forms require special treatment: the way to put two forms on one line in HTML is to put them in a table:
<html>
<body>
<table cellpadding=0 cellspacing=0>
<tr><td>
<form name="orderform" action="order.php" method="POST">
<label>Username</label>
<input name="user" type="text" value="" size="10" maxlength="22">
<label>Items</label>
<select name="mydropdown">
<option value="macbook">Macbook</option>
<option value="sony">Sony</option>
<option value="micromax">Micromax</option>
<option value="napolean">Napolean</option>
<option value="motorola">Motorola</option>
</select>
<label>Quantity</label>
<select name="mydropdown">
<option value="quantity1">1</option>
<option value="quantity2">2</option>
<option value="quantity3">3</option>
<option value="quantity4">4</option>
<option value="quantity5">5</option>
</select>
<input name="Order" type="submit" value="Order">
</form>
<td>
<form name="orderform" action="addtocart.php" method="POST">
<input name="Cart" type="submit" value="Add to Cart">
</form>
</table>
</body>
</html>

Some inputs not submitted

I have an HTML form but some of the inputs in it are not submitted, even though they are active. Live example at http://jsfiddle.net/hbw3/qzcTS/2/.
The form clearly contains a number of divs but only the inputs in one div are submitted. Why is this?
The HTML source:
<form accept-charset="UTF-8" action="whatever" id="map_form" method="post">
<table>
<tr>
<td>
<select id=1 name=col_1 class="column_select">
<option value="0">None</option>
<option value="1">id (integer)</option>
<option value="2">name (string)</option>
</select>
</td>
<td>
<select id=2 name=col_2 class="column_select">
<option value="0">None</option>
<option value="1">id (integer)</option>
<option value="2">name (string)</option>
</select>
</td>
</tr>
</table>
<div class="span4" id="default_values">
<label for='id' class='control-label'>id (integer)</label>
<input type='text' id='id' />
<label for='name' class='control-label'>name (string)</label>
<input type='text' id='name' />
</div>
<input name="commit" type="submit" value="Upload Table" />
</form>
<div id='result'></div>
The JS to display the submitted inputs:
$('form#map_form').submit(function () {
$('div#result').text($(this).serialize());
return false;
})
You're missing name attributes on the inputs in your last div. I tried adding some to your sample and that seems to have fixed it.