selection structure nested within another selection structure

4

4Ankit

Hey guys i am having some trouble with nesting one selection structure
within another selection structure. At the moment i am unclear what
selection structures are and just need a simple example of a selection
structure within another selection structure. I am supposed to use
function definitions with parameters to validate a form. my code for
what i have done so far is as follows(cropped):


function mainFunction() {
var dateFormat = (document.dateFormat.date.value + " " +
document.dateFormat.month.value + ", " +
document.dateFormat.year.value);
window.alert("The date is " + dateFormat);}
return; }

function checkDate( ) {
if (0<parseInt(document.dateFormat.date.value) &&
parseInt(document.dateFormat.date.value)<=31) {
return true;}
else {window.alert("Problem with the date");
return false;} }

Basically how can i change the above checkDate function in include a
selection structure nested within another selection
structure.Eventually i will have another 2 functions which will b used
to validate the year and month the user enters. Your help would be
great :)
Have a nice day
 
A

ASM

(e-mail address removed) a écrit :
Basically how can i change the above checkDate function in include a
selection structure nested within another selection
structure.Eventually i will have another 2 functions which will b used
to validate the year and month the user enters.

function checkDate( whatForm ) {
var v = document.forms[whatForm].date.value
if (0<=v && parseInt(v)<=31) return true;
else {
window.alert("Problem with the date");
v.focus();
return false;
}
}

function checkMonth( whatForm ) {
var v = document.forms[whatForm].month.value
if (0<=v && parseInt(v)<=12) return true;
else {
window.alert("Problem with the month");
v.focus();
return false;
}
}
function checkYear( whatForm ) {
var v = ... etc ...
}

function mainFunction( whatForm ) {
checkDat(whatForm);
checkMonth(whatForm);
checkYear(whatForm);
var dateFormat = (d ... etc ...
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top