I have alot of these "if" statements ( I listed 2 as an example) and would like to put them in a case statement. My ifs work great for checking blank spaces in my form but now I would like to make it all into case statements.
function stdRequire()
{
stdInfo = ''
ct = 0
if(/^\s*$/.test(document.stand.poc_fnm.value))
{
stdInfo += "\npoc first name";
ct++;
}
if(/^\s*$/.test(document.stand.poc_lnm.value))
{
stdInfo += "\npoc last name";
ct++;
}
etc...
if (stdInfo != '')
{
alert(stdInfo);
return false;
}
}
/////
//My attempt using CASE statements:
/////
function stdRequire()
{
stdInfo = ''
ct = 0
switch(n)
{
case(/^\s*$/.test(document.stand.poc_fnm.value):
stdInfo += "\nPOC's First Name";
ct++;
break;
case(/^\s*$/.test(document.stand.poc_lnm.value):
stdInfo += "\nPOC's Last Name";
ct++;
break;
etc...
Any advice on if this is correct??
function stdRequire()
{
stdInfo = ''
ct = 0
if(/^\s*$/.test(document.stand.poc_fnm.value))
{
stdInfo += "\npoc first name";
ct++;
}
if(/^\s*$/.test(document.stand.poc_lnm.value))
{
stdInfo += "\npoc last name";
ct++;
}
etc...
if (stdInfo != '')
{
alert(stdInfo);
return false;
}
}
/////
//My attempt using CASE statements:
/////
function stdRequire()
{
stdInfo = ''
ct = 0
switch(n)
{
case(/^\s*$/.test(document.stand.poc_fnm.value):
stdInfo += "\nPOC's First Name";
ct++;
break;
case(/^\s*$/.test(document.stand.poc_lnm.value):
stdInfo += "\nPOC's Last Name";
ct++;
break;
etc...
Any advice on if this is correct??