/    Sign up×
Community /Pin to ProfileBookmark

Java Script Codes

Plz i need your help in Java Script reservation form:
1) How to change the text on the Java Script alert window.
2) How to make the terms & conditions check box is required to submit form.

3) When form is filled how to make a window shows that the bookings has been submit.

Thank you so much for the great assistance you provide ?

Rehab (Ms.)
From Cairo – Egypt

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@jedaisoulAug 15.2015 — Sounds like homework to me? I think you should at least try to do the work yourself. Then if you get stuck, post your code so people here can help. Besides which: what reservation form???
Copy linkTweet thisAlerts:
@srehabsauthorAug 16.2015 — Thanks for your reply Sir but it's not a homework.

This is a form of travel package.

I'm stuck on these matters:

[COLOR=#333333]1) How to change the text on the Java Script alert window.

[COLOR=#333333]2) How to make the terms & conditions check box is required to submit form.

[COLOR=#333333]3) When form is filled how to make a window shows that the bookings has been submit.



Below is not the full reservation form it's only parts of it as it's too long, attached pic how it looks like[ATTACH]16787[/ATTACH]



Thank you once more ?





Here is the code:

Javascript code:

<i>
</i>&lt;script language="javascript"&gt;
function calculate(form)
{
var dbl = form.dbl.value;
var t_dbl = form.t_dbl.value;
var tpl = form.tpl.value;
var t_tpl = form.t_tpl.value;
var sgl = form.sgl.value;
var t_sgl = form.t_sgl.value;
var chd = form.chd.value;
var t_chd = form.t_chd.value;
var inf = form.inf.value;
var t_inf = form.t_inf.value;
var grand_total = form.grand_total.value;
form.t_dbl.value = (parseInt(dbl) * 1390);
form.t_tpl.value = (parseInt(tpl) * 2085);
form.t_sgl.value = (parseInt(sgl) * 945);
form.t_chd.value = (parseInt(chd) * 350);
form.t_inf.value = (parseInt(inf) * 250);

form.grand_total.value = (parseInt(form.t_dbl.value) +
parseInt(form.t_tpl.value) + parseInt(form.t_sgl.value) + parseInt(form.t_chd.value)+ parseInt(form.t_inf.value));
}
function MM_validateForm() { //v4.0
if (document.getElementById){
var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
for (i=0; i&lt;(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
if (val) { nm=val.name; if ((val=val.value)!="") {
if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
if (p&lt;1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.n';
} else if (test!='R') { num = parseFloat(val);
if (isNaN(val)) errors+='- '+nm+' must contain a number.n';
if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
min=test.substring(8,p); max=test.substring(p+1);
if (num&lt;min || max&lt;num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.n';
} } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.n'; }
} if (errors) alert('The following error(s) occurred:n'+errors);
document.MM_returnValue = (errors == '');
} }
&lt;/script&gt;


[code=html]
<form name="form1" method="post" action="">
<table width="600">
<tr>
<td colspan="2" >* Title:</td>
<td colspan="2" ><select name="select" id="select">
<option selected>Dr.</option>
<option>Mr.</option>
<option>Mrs.</option>
<option>Ms.</option>
</select></td>
</tr>
<tr>
<td colspan="2">* Family Name:</td>
<td colspan="2"><input name="family name" type="text" id="family name"></td>
</tr>
<tr>
<td colspan="2">* First Name:</td>
<td colspan="2"><input name="First Name" type="text" id="first name"></td>
</tr>
<tr>
<td colspan="2">* E-mail:</td>
<td colspan="2"><input name="email" type="text" id="email" onBlur="MM_validateForm('email','','RisEmail');return document.MM_returnValue" size="25"></td>
</tr>
<tr>
<td colspan="2"><label for="select2">* No of adults: </label></td>
<td colspan="2"><select name="select2" id="select2">
<option selected>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr>
<td colspan="2"><label for="select3">* No of children: </label></td>
<td colspan="2"><select name="select3" id="select3">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr>
<td colspan="2">* No of infant:</td>
<td colspan="2"><select name="select4" class="bg2" id="select6">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
</tr>
<tr >
<td><label for="select7"></label>
<select name="dbl" id="dbl" onChange="calculate(this.form)" >
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Double room $ 695 X 02 persons: $ 1390</td>
<td ><input name="t_dbl" type="text" id="t_dbl" value="0" size="10" readonly></td>
</tr>
<tr align="right">
<td> <select name="tpl" onChange="calculate(this.form)" id="tpl">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Triple room $ 695 X 03 persons: $ 2085</td>
<td ><input name="t_tpl" type="text" id="t_tpl" value="0" size="10" readonly></td>
</tr>
<tr>
<td ><select name="sgl" onChange="calculate(this.form)" id="sgl">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Single room $ 945 X 01 person: $ 945</td>
<td><input name="t_sgl" type="text" id="t_sgl" value="0" size="10" readonly></td>
</tr>
<tr>
<td><select name="chd" onChange="calculate(this.form)" id="chd">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Child $ 350 X 01 child: $ 350</td>
<td><input name="t_chd" type="text" id="t_chd" value="0" size="10" readonly></td>
</tr>
<tr>
<td><select name="inf" onChange="calculate(this.form)" id="inf">
<option selected>0</option>
<option>1</option>
<option>2</option>
<option>3</option>
</select></td>
<td colspan="2">Price per Infant $ 250 X 01 infant:$ 250</td>
<td ><input name="t_inf" type="text" class="bg3" id="t_inf" value="0" size="10" readonly>

<label for="textfield5"></label></td>
</tr>
<tr>
<td>*</td>
<td colspan="2">*</td>
<td align="center">*</td>
</tr>
<tr >
<td><input name="grand_total" type="text" id="grand_total" value="0" size="10" readonly></td>
</tr>
<tr>
<td><input type="checkbox" name="I have read and accept the Terms & Conditions." id="I have read and accept the Tems & Conditions.">
<label for="I have read and accept the Terms & Conditions.">I have read and accept the Terms & Conditions.</label></td>
</tr>
<tr >
<td colspan="3"><input name="Submit" type="submit" id="Submit" value="Submit"></td>
<td><input type="Reset" name="Reset" id="Reset" value="Reset"></td>
</tr>
</table>
</form>
[/code]


[canned-message]attachments-removed-during-migration[/canned-message]
Copy linkTweet thisAlerts:
@jedaisoulAug 16.2015 — Homework or not, we do not write code to order, particularly not for free. If you make an attempt at amending the code and have specific issues we can often help.
Copy linkTweet thisAlerts:
@srehabsauthorAug 17.2015 — [ATTACH]16791[/ATTACH]

Thanks again for your reply.

Well try to make myself more particular.

1) How to change the text on the Java Script error alert window. "attached No.1"

It says JavaScript Alert: the following error(s) required.

Can we change the text (Java Script error alert).

2) How to make check box form required to submit form.

<input type="checkbox" name="I have read and accept the Terms &amp; Conditions."

id="I have read and accept the Terms &amp; Conditions.">

<label for="I have read and accept the Terms &amp; Conditions.">I have read and accept the Terms &

Conditions.</label>

3) When the whole form is filled how to make a window shows "the end user" that the form has been submit.

<input name="Submit" type="submit" id="Submit" value="Submit">

Hope this is clear and there is possibility to help me.

Thanks again,

Rehab

[canned-message]attachments-removed-during-migration[/canned-message]
×

Success!

Help @srehabs spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...