Hello everyone,

I'm trying to combine 3 form input fields into 1 that is hidden (Date of Birth). The input fields are DOB-MM, DOB-DD, and DOB-YYYY and the hidden field is DOB which will store the Date of Birth in the following format 'YYYY-MM-DD'. Unfortunately I don't know javascript so I hope someone can help me write a quick script that will combine these 3 fields and arrange them in the format required.

Thank you in advance!


<form name="signup" action="{{{form_url}}}" class="appnitro" method="post" >
					<div class="form_description">
			<h2>Newsletter Sign-up</h2>
			<ul >
					<li id="li_1" >
		<label class="description" for="person_name">Name / Nombre </label>
			<input id="person_first_name" name= "person[first_name]" class="element text" maxlength="255" size="20" value="{{{first_name}}}"/>
			<label>First Name / Nombre</label>
			<input id="person_last_name" name= "person[last_name]" class="element text" maxlength="255" size="20" value="{{{last_name}}}"/>
			<label>Last Name / Apellido</label>
		</span>		</li>		<li id="li_3" >
		<label class="description" for="person_email_address">Email / Correo Electronico * (Required)</label>
			<input id="person_email_address" name="person[email_address]" class="element text medium" type="text" maxlength="255" value="{{{email_address}}}"/> 
		</li>		<li id="li_4" >
		<label class="description" for="person_dob">Date of Birth / Fecha de Nacimiento </label>
			<input id="person_dobmm" name="person[dobmm]" class="element text" size="2" maxlength="2" value="{{{dobmm}}}" type="text"> /
			<label for="DOB-MM">MM</label>
			<input id="person_dobdd" name="person[dobdd]" class="element text" size="2" maxlength="2" value="{{{dobdd}}}" type="text"> /
			<label for="DOB-DD">DD</label>
	 		<input id="person_dobyyyy" name="person[dobyyyy]" class="element text" size="4" maxlength="4" value="{{{dobyyyy}}}" type="text">
			<label for="DOB-YYYY">YYYY</label>
			<input id="person_dob" name="person[dob]" start_year="1910" type="hidden" value="{{{dob}}}" />
		<li class="buttons">
				<input class="button_text" type="submit" name="commit" value="Sign Up" />

Recommended Answers

All 3 Replies

Member Avatar
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<title> New Document </title>
<meta name="Generator" content="EditPlus">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<script language="javascript">
function check(){
	var text=yyyy.value+"-"+mm.value+'-'+dd.value;
MM <input type="text" size="2" name="mm">
DD <input type="text" size="2" name="dd">
YY <input type="text" size="4" name="yyyy">
<input type="submit" name="commit" value="Submit" onClick="check()">
<input type="hidden" size="10" name="dob" value="test">

Hello RajaRajan.R,

Thank you for your reply. One quick question about your code. Should the value of the line below be test or text?

<input type="hidden" size="10" name="dob" value="test">



Member Avatar

Dont worry about that, it is "test" only it is a default value displayed in the hidden field, you can also leave it simply with "". We change the "test" to "1998-5-12" in javascript using that name of the hidden field.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.