Solved

Enable/Disable specific validations of a validation script depending on what user chooses

Posted on 2004-08-28
23
527 Views
Last Modified: 2012-06-21
I have a credit card application form on my site.. it's currently validated by a javascript.. there's an option for the user to add a secondary card holder. the problem is if the user chooses to add a secondary card holder - the validation must be enabled to make sure the user enters all the information for the secondary card holder correctly..

if the user chooses not to add a secondary card holder - then the validation for this area must be disabled..

can this be done with my current script? i will provide example page and validation code
0
Comment
Question by:andreni78
  • 14
  • 6
  • 3
23 Comments
 

Author Comment

by:andreni78
Comment Utility
You will see custom validation commands at the bottom of the example page

This is the example page: http://majestic.gotdns.com/test.html

The code:
<script>
var ORIGINAL_TEXT_COLOR = "black";
var ERROR_TEXT_COLOR = "white";
function Validator(frmname){

   this.formobj=document.forms[frmname];
    if(!this.formobj)
    {
      alert("BUG: couldnot get Form object "+frmname);
         return;
    }
    if(this.formobj.onsubmit)
    {
     this.formobj.old_onsubmit = this.formobj.onsubmit;
     this.formobj.onsubmit=null;
    }
    else
    {
     this.formobj.old_onsubmit = null;
    }
    this.formobj.onsubmit=form_submit_handler;
    this.addValidation = add_validation;
    this.setAddnlValidationFunction=set_addnl_vfunction;
    this.clearAllValidations = clear_all_validations;
}

function set_addnl_vfunction(functionname)
{
 this.formobj.addnlvalidation = functionname;
}

function clear_all_validations()
{
    for(var itr=0;itr < this.formobj.elements.length;itr++)
    {
         this.formobj.elements[itr].validationset = null;
    }
}

var errMsg;

function form_submit_handler(){
    errMsg = "";
    var retVal = true;
    var firstFrmValidateFailedObj;

    for(var itr=0;itr < this.elements.length;itr++)
    {
         if(this.elements[itr].validationset &&

!this.elements[itr].validationset.validate())
         {
           retVal = false;
           if(typeof(firstFrmValidateFailedObj) == "undefined"){

                     firstFrmValidateFailedObj = this.elements[itr];
                }
         }
    }

   if(errMsg>""){
         alert("Please correct these errors:"+errMsg);
         if(typeof(firstFrmValidateFailedObj) != "undefined"){
             

firstFrmValidateFailedObj.style.color=ORIGINAL_TEXT_COLOR;
              if(firstFrmValidateFailedObj.type == "text" ||

firstFrmValidateFailedObj.type == "textarea"){
               firstFrmValidateFailedObj.select();
              }
          firstFrmValidateFailedObj.focus();
     }
     return false;
   } else {
     document.getElementById("Submit").disabled=true;
   }


   if(retVal && this.addnlvalidation){
      str =" var ret = "+this.addnlvalidation+"()";
      eval(str);
          if(retVal && !ret) return ret;
   }
   return retVal;
}


function add_validation(itemname,descriptor,errstr)
{
    if(!this.formobj)
    {
         alert("BUG: the form object is not set properly");
         return;
    }//if
    var itemobj = this.formobj[itemname];

   if(itemobj.length && isNaN(itemobj.selectedIndex) )
   //for radio button; don't do for 'select' item
    {
         itemobj = itemobj[0];
    }
     if(!itemobj)
    {
         alert("BUG: Couldnot get the input object named:

"+itemname);
         return;
    }

     if(!itemobj.validationset)
    {
         itemobj.validationset = new ValidationSet(itemobj);
    }
    itemobj.validationset.add(descriptor,errstr);
}


function ValidationDesc(inputitem,desc,error)
{
   this.desc=desc;
    this.error=error;
    this.itemobj = inputitem;
    this.validate=vdesc_validate;
}


function vdesc_validate(){
  if(!this.itemobj.oldColor){
    this.itemobj.oldColor =

"color:"+this.itemobj.style.backgroundColor;
  }
  if(!validateInput(this.desc,this.itemobj,this.error)){
    this.itemobj.style.backgroundColor="red"
    this.itemobj.style.color=ERROR_TEXT_COLOR;
    this.itemobj.focus();
    this.itemobj.onkeydown =

function(){this.style.backgroundColor=this.oldColor.split("color:")[1

];this.style.color=ORIGINAL_TEXT_COLOR};
     this.itemobj.onclick = this.itemobj.onkeydown;
     return false;
  } else {
     

this.itemobj.style.backgroundColor=this.itemobj.oldColor.split("color

:")[1];
     return true;
  }
}

function ValidationSet(inputitem)
{
   this.vSet=new Array();
    this.add= add_validationdesc;
    this.validate= vset_validate;
    this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
 this.vSet[this.vSet.length]=
  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
      {
        if(!this.vSet[itr].validate())
           {
             return false;
           }
      }
      return true;
}

/*  checks the validity of an email address entered
*   returns true or false
*/
function validateEmail(email)
{
   var splitted = email.match("^(.+)@(.+)$");
   if(splitted == null) return false;
   if(splitted[1] != null )
   {
     var regexp_user=/^\"?[\w-_\.]*\"?$/;
     if(splitted[1].match(regexp_user) == null) return false;
   }
   if(splitted[2] != null)
   {
     var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
     if(splitted[2].match(regexp_domain) == null)
      {
        var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
        if(splitted[2].match(regexp_ip) == null) return false;
     }// if
     return true;
   }
return false;
}

function

TestComparison(objValue,strCompareElement,strvalidator,strError)
{
  var bRet=true;
  var objCompare=null;
  if(!objValue.form)
  {
     alert("BUG: No Form object!");
      return false
  }
  objCompare = objValue.form.elements[strCompareElement];
  if(!objCompare)
  {
    alert("BUG: Element with name"+strCompareElement+" not found !");
    return false;
  }
  if(strvalidator != "eqelmnt" &&
         strvalidator != "neelmnt")
  {
     if(isNaN(objValue.value))
      {
        errMsg += "\n\t"+objValue.name+": Should be a number ";
        return false;
      }//if
      if(isNaN(objCompare.value))
      {
        errMsg += "\n\t"+objCompare.name+": Should be a number ";
        return false;
      }//if
  }//if
  var cmpstr="";
  switch(strvalidator)
  {
      case "eqelmnt":
               {
                 if(objValue.value != objCompare.value)
                 {
                      cmpstr = " should be equal to ";
                    bRet = false;
                 }//if
                 break;
              }//case
         case "ltelmnt":
              {
              if(eval(objValue.value) >= eval(objCompare.value))
                    {
                     cmpstr =  " should be less than ";
                      bRet = false;
                    }
                break;
              }//case
         case "leelmnt":
              {
                   if(eval(objValue.value) >  eval(objCompare.value))
                    {
                     cmpstr =  " should be less than or equal to";
                      bRet = false;
                    }
                break;
              }//case
         case "gtelmnt":
              {
                   if(eval(objValue.value) <=  

eval(objCompare.value))
                    {
                     cmpstr =  " should be greater than";
                      bRet = false;
                    }
                break;
              }//case
         case "geelmnt":
              {
                   if(eval(objValue.value) < eval(objCompare.value))
                    {
                     cmpstr =  " should be greater than or equal to";
                      bRet = false;
                    }
                break;
              }//case
         case "neelmnt":
              {
                 if(objValue.value.length > 0 &&
                   objCompare.value.length > 0 &&
                   objValue.value == objCompare.value)
                 {
                      cmpstr = " should be different from ";
                    bRet = false;
                 }//if
                 break;
               }
   }//switch
  if(bRet==false)
  {
     if(!strError || strError.length==0)
      {
        strError = objValue.name + cmpstr + objCompare.value;
       }//if
      errMsg += "\n\t"+strError;
  }//if
  return bRet;
}
function TestSelMin(objValue,strMinSel,strError)
{
   var bret = true;
    var objcheck = objValue.form.elements[objValue.name];
    var chkcount =0;
    if(objcheck.length)
    {
         for(var c=0;c < objcheck.length;c++)
         {
            if(objcheck[c].checked == "1")
            {
              chkcount++;
            }//if
         }//for
    }
    else
    {
      chkcount = (objcheck.checked == "1")?1:0;
    }
    var minsel = eval(strMinSel);
    if(chkcount < minsel)
    {
         if(!strError || strError.length ==0)
          {
               strError = "Please Select atleast"+minsel+" check

boxes for"+objValue.name;
         }//if
          errMsg += "\n\t"+strError;
          bret = false;
    }
    return bret;
}

function TestDontSelectChk(objValue,chkValue,strError)
{
   var pass=true;
    var objcheck = objValue.form.elements[objValue.name];
   if(objcheck.length)
    {
         var idxchk=-1;
         for(var c=0;c < objcheck.length;c++)
         {
            if(objcheck[c].value == chkValue)
            {
              idxchk=c;
               break;
            }//if
         }//for
         if(idxchk>= 0)
         {
           if(objcheck[idxchk].checked=="1")
           {
             pass=false;
           }
         }//if
    }
    else
    {
         if(objValue.checked == "1")
         {
              pass=false;
         }//if
    }//else
    if(pass==false)
    {
    if(!strError || strError.length ==0)
        {
             strError = "Can't Proceed as you selected

"+objValue.name;
       }//if
       errMsg += "\n\t"+strError;

     }
   return pass;
}

function TestRequiredInput(objValue,strError)
{
var ret = true;
   if(eval(objValue.value.length) == 0)
    {
       if(!strError || strError.length ==0)
       {
         strError = objValue.name + " : Required Field";
       }//if
       errMsg += "\n\t"+strError;
       ret=false;
    }//if
return ret;
}

function TestMaxLen(objValue,strMaxLen,strError)
{
var ret = true;
   if(eval(objValue.value.length) > eval(strMaxLen))
    {
      if(!strError || strError.length ==0)
      {
        strError = objValue.name + " : "+ strMaxLen +" characters

maximum ";
      }//if
      errMsg += "\n\t"+strError + "\n\t[Current length = " +

objValue.value.length + "]";
      ret = false;
    }//if
return ret;
}

function TestMinLen(objValue,strMinLen,strError)
{
var ret = true;
   if(eval(objValue.value.length) <  eval(strMinLen))
    {
      if(!strError || strError.length ==0)
      {
        strError = objValue.name + " : " + strMinLen + " characters

minimum  ";
      }//if
      errMsg += "\n\t"+strError + "\n\t[Current length = " +

objValue.value.length + "]";
      ret = false;
    }//if
return ret;
}

function TestInputType(objValue,strRegExp,strError,strDefaultError)
{
  var ret = true;

   var charpos = objValue.value.search(strRegExp);
    if(objValue.value.length > 0 &&  charpos >= 0)
    {
     if(!strError || strError.length ==0)
      {
        strError = strDefaultError;
     }//if
      errMsg += "\n\t"+strError + "\n\t [Error character position " +

eval(charpos+1)+"]";
      ret = false;
    }//if
 return ret;
}

function TestEmail(objValue,strError)
{
var ret = true;
    if(objValue.value.length > 0 && !validateEmail(objValue.value)    

  )
     {
       if(!strError || strError.length ==0)
       {
          strError = objValue.name+": Enter a valid Email address ";
       }//if
       errMsg += "\n\t"+strError;
       ret = false;
     }//if
return ret;
}

function TestLessThan(objValue,strLessThan,strError)
{
var ret = true;
      if(isNaN(objValue.value))
       {
         errMsg += "\n\t"+objValue.name+": Should be a number ";
         ret = false;
       }//if
       else
      if(eval(objValue.value) >=  eval(strLessThan))
       {
         if(!strError || strError.length ==0)
         {
           strError = objValue.name + " : value should be less than

"+ strLessThan;
         }//if
         errMsg += "\n\t"+strError;
         ret = false;
        }//if
return ret;
}

function TestGreaterThan(objValue,strGreaterThan,strError)
{
var ret = true;
    if(isNaN(objValue.value))
     {
       errMsg += "\n\t"+objValue.name+": Should be a number ";
       ret = false;
     }//if
      else
    if(eval(objValue.value) <=  eval(strGreaterThan))
      {
        if(!strError || strError.length ==0)
        {
          strError = objValue.name + " : value should be greater than

"+ strGreaterThan;
        }//if
        errMsg += "\n\t"+strError;
       ret = false;
     }//if
return ret;
}

function TestRegExp(objValue,strRegExp,strError)
{
var ret = true;
   if( objValue.value.length > 0 &&
        !objValue.value.match(strRegExp) )
    {
      if(!strError || strError.length ==0)
      {
        strError = objValue.name+": Invalid characters found ";
      }//if
      errMsg += "\n\t"+strError;
      ret = false;
    }//if
return ret;
}
function TestDontSelect(objValue,index,strError)
{
var ret = true;
    if(objValue.selectedIndex == null)
     {
       alert("BUG: dontselect command for non-select Item");
       ret = false;
     }
      else
    if(objValue.selectedIndex == eval(index))
     {
      if(!strError || strError.length ==0)
       {
       strError = objValue.name+": Please Select one option ";
       }//if
       errMsg += "\n\t"+strError;
       ret =  false;
      }
return ret;
}

function TestSelectOneRadio(objValue,strError)
{
    var objradio = objValue.form.elements[objValue.name];
    var one_selected=false;
    for(var r=0;r < objradio.length;r++)
    {
      if(objradio[r].checked == "1")
      {
           one_selected=true;
         break;
      }
    }
    if(false == one_selected)
    {
     if(!strError || strError.length ==0)
       {
        strError = "Please select one option from "+objValue.name;
       }
       errMsg += "\n\t"+strError;
    }
return one_selected;
}

//*  Checks each field in a form
function validateInput(strValidateStr,objValue,strError)
{
    var ret = true;
   var epos = strValidateStr.search("=");
    var  command  = "";
    var  cmdvalue = "";
    if(epos >= 0)
    {
     command  = strValidateStr.substring(0,epos);
     cmdvalue = strValidateStr.substr(epos+1);
    }
    else
    {
     command = strValidateStr;
    }

    switch(command)
    {
        case "req":
        case "required":
         {
             ret = TestRequiredInput(objValue,strError)
          break;
         }
       case "maxlength":
        case "maxlen":
          {
                ret = TestMaxLen(objValue,cmdvalue,strError)
            break;
          }
       case "minlength":
        case "minlen":
           {
                ret = TestMinLen(objValue,cmdvalue,strError)
            break;
           }
       case "alnum":
        case "alphanumeric":
           {
                    ret =

TestInputType(objValue,"[^A-Za-z0-9]",strError,objValue.name+": Only

alpha-numeric characters allowed ");
                   break;
           }
       case "alnum_s":
        case "alphanumeric_space":
           {
                    ret =

TestInputType(objValue,"[^A-Za-z0-9\\s]",strError,objValue.name+":

Only alpha-numeric characters and space allowed ");
                   break;
           }
        case "num":
        case "numeric":
           {
                ret =

TestInputType(objValue,"[^0-9]",strError,objValue.name+": Only digits

allowed ");
               break;
           }
       case "alphabetic":
        case "alpha":
           {
                ret =

TestInputType(objValue,"[^A-Za-z]",strError,objValue.name+": Only

alphabetic characters allowed ");
               break;
           }
       case "alphabetic_space":
        case "alpha_s":
           {
                ret =

TestInputType(objValue,"[^A-Za-z\\s]",strError,objValue.name+": Only

alphabetic characters and space allowed ");
               break;
           }
       case "email":
          {
                  ret = TestEmail(objValue,strError);
              break;
          }
       case "lt":
        case "lessthan":
         {
               ret = TestLessThan(objValue,cmdvalue,strError);
             break;
         }
       case "gt":
        case "greaterthan":
         {
               ret = TestGreaterThan(objValue,cmdvalue,strError);
           break;
         }
       case "regexp":
         {
               ret = TestRegExp(objValue,cmdvalue,strError);
          break;
         }
       case "dontselect":
         {
                ret = TestDontSelect(objValue,cmdvalue,strError)
            break;
         }
         case "dontselectchk":
         {
              ret = TestDontSelectChk(objValue,cmdvalue,strError)
              break;
         }
         case "selmin":
         {
              ret = TestSelMin(objValue,cmdvalue,strError);
              break;
         }
         case "selone":
         {
              ret = TestSelectOneRadio(objValue,strError);
             break;
         }
          //Comparisons
         case "eqelmnt":
          case "ltelmnt":
         case "leelmnt":
         case "gtelmnt":
         case "geelmnt":
         case "neelmnt":
         {
             return

TestComparison(objValue,cmdvalue,command,strError);
             break;
         }
   }//switch
    return ret;
}
</script>


<form name="myform">
Primary Cardholder information
<select name="name1">
<option>Mr
<option>Mrs
<option>Ms
</select>
First Name<input type=text name="name2">
Last Name<input type=text name="name3">
<br>
<input type=radio name="name4" value="One"> One
<input type=radio name="name4" value="Two"> Two
<input type=radio name="name4" value="Three"> Three
<br>
<input type=checkbox name="name5" value="One"> One
<input type=checkbox name="name5" value="Two"> Two
<input type=checkbox name="name5" value="Three"> Three

<br>
<br>
would you like to add another card holder?
<select name=test>
<option value="">select</option>
<option value=yes>yes</option>
<option value=no>no</option>
</select>
<br>
Enter secondary cardholder information:<br>
First Name: <input type=text name=second_fname>
Last Name: <input type=text name=second_lname>

<br><br>
<input type=submit>
</form>

<!-- This is where the validation commands are -->

<SCRIPT language=JavaScript type="text/javascript">
 var frmvalidator  = new Validator("myform");
<!-- for select list form, uses "dontselect=0" -->
 frmvalidator.addValidation("name1","dontselect=0","Select list error

message");
<!-- "req" is for required entry for inputbox -->
 frmvalidator.addValidation("name2","req","inputbox error message");
<!-- "minlen=#" is minimum length requirement -->
 frmvalidator.addValidation("name3","minlen=3", "inputbox minimum

length error message");
<!-- "selone" is for radio box requirement selection -->
 frmvalidator.addValidation("name4","selone","Radio box error

message");
<!-- "selmin" is for checkbox requirement -->
 frmvalidator.addValidation("name5","selmin=1","checkbox error

message");
</script>
0
 

Author Comment

by:andreni78
Comment Utility
i've modified the code on my example page.. all i added was validation for the secondary card holder yes/no option
0
 
LVL 1

Expert Comment

by:John-Doe
Comment Utility

Suppose you have solved it?
-----------------------------------------------------------------
if(document.getElementById('test').value=='yes')
{
  //do the validation of the secondary card holder..
}
-----------------------------------------------------------------

Else i might only give some tips(if you are not avare of them..):

You have to add an id to all the elemts in the form, ie <input type=submit> have no id, but you reffer to it in your code.

The actuall check of the CreditCard number should be done by the luhn logarithm.

You also have defined values for the different card types:
VISA: length of number 16 or 13 - and have to start with 4
AMEX: length of number 15 - have to start with 3 - second digit must be 4 or 7
MASTERCARD: length of number 16 - have to start with 5 - second digit must be 1,2,3,4 or 5
DINERS:  length of number 14 - first digit must be 3 - second digit must be 0,6 or 8
DISCOVER: length of number 16 - first 4 digits must be 6011

one way to do this are(by adding one case for each type..):
-----------------------------------------------------------------
function validateCardByType(strCardType,strCardNumber)
{
 var ccLength  = strCardNumber.length;
 var cc1Digit  = strCardNumber.substring(0,1);
 var cc2Digit  = strCardNumber.substring(1,2);

  switch (strCardType)
  {
      case "AMEX":
            var valSubNumbers = "47";
            result = (ccLength == 15) && (cc1Digit == "3") && (valSubNumbers.indexOf(cc2Digit)>=0);
            break;
  }
  return result;
}
-----------------------------------------------------------------

You could also use something like this to remove no-numbers.

-----------------------------------------------------------------
function allDigits(str)
{
      return str.replace(/[^0-9]/g,"");
}
-----------------------------------------------------------------

Br,
  -JD
0
 

Author Comment

by:andreni78
Comment Utility
thanks for the CC# validations but i'm not looking for that.. i'm just looking for.. if the user decides to add secondary cardholder information.. then the secondary cardholder validations will be enabled.. if the user decides no.. then the secondary cardholder validations REMAINS DISABLED...

currently whether you select yes or no.. there's no validation for the secondary cardholder information... i hope this is clear..
0
 
LVL 1

Expert Comment

by:John-Doe
Comment Utility
Should the second cardholder have the additional values?
(The Check- and optionboxes One, Two and Three)
0
 
LVL 1

Expert Comment

by:John-Doe
Comment Utility
1. Add an id to <input type=submit> ... as: <input type=submit id="Submit">
2. <select name="name1"> and corresponding check have a fault so one get invalid selection if one select "Mr".
   Either remove the entire validation of this field (Remove: frmvalidator.addValidation("name1","dontselect=0","Select list error message");)
   Or add one mor option so Mr do not have index 0:

<select name="name1">
  <option value="0">Title</option>
  <option value="Mr">Mr</option>
  <option value="Mrs">Mrs</option>
  <option value="Ms">Ms</option>
</select>

3. Before the very last "</script>" add:
   <!-- "req" is for required entry for inputbox -->
   frmvalidator.addValidation2("second_fname","req","inputbox error message");
   <!-- "minlen=#" is minimum length requirement -->
   frmvalidator.addValidation2("second_lname","minlen=3", "inputbox minimum length error message");

4. rewrite the function form_submit_handler() to something like this:
----------------------------------------------------------
function form_submit_handler(){
    errMsg = "";
    var retVal = true;
    var firstFrmValidateFailedObj;
    var valSecondCardh = false;

    for(var itr=0;itr < this.elements.length;itr++)
    {
       if(this.elements[itr].name=="test")
       {
         if(this.elements[itr].value=="yes"){valSecondCardh=true;}
       }

       if((this.elements[itr].name=="second_fname"||this.elements[itr].name=="second_lname") && !valSecondCardh)
       {
         break;
       }

         if(this.elements[itr].validationset && !this.elements[itr].validationset.validate())
         {
           retVal = false;
           if(typeof(firstFrmValidateFailedObj) == "undefined"){

                     firstFrmValidateFailedObj = this.elements[itr];
                }
         }
    }

   if(errMsg>""){
         alert("Please correct these errors:"+errMsg);
         if(typeof(firstFrmValidateFailedObj) != "undefined"){
              firstFrmValidateFailedObj.style.color=ORIGINAL_TEXT_COLOR;
              if(firstFrmValidateFailedObj.type == "text" || firstFrmValidateFailedObj.type == "textarea"){
               firstFrmValidateFailedObj.select();
              }
          firstFrmValidateFailedObj.focus();
     }
     return false;
   } else {
     document.getElementById("Submit").disabled=true;
   }


   if(retVal && this.addnlvalidation){
      str =" var ret = "+this.addnlvalidation+"()";
      eval(str);
          if(retVal && !ret) return ret;
   }
   return retVal;
}
----------------------------------------------------------

// ADDED ARE:
  var valSecondCardh = false;
 
// AND

       if(this.elements[itr].name=="test")
       {
         if(this.elements[itr].value=="yes"){valSecondCardh=true;}
       }

       if((this.elements[itr].name=="second_fname"||this.elements[itr].name=="second_lname") && !valSecondCardh)
       {
         break;
       }
0
 

Author Comment

by:andreni78
Comment Utility
hmm currently the script has built in functions for all the validations.. can we use that?

if i wanted to add a validation to an inputbox.. this is what i would type

frmvalidator.addValidation("name2","req","inputbox error message");

"name2" is the inputbox name.. "req" is for required input.. and "inputbox error message" is self explanatory..

what i'd like is if you can make the script have a sub function that's called when a certain input has occurred..
ideally the call to that sub function would be contained within the script.. say

frmvalidator.addValidation("name2","req","inputbox error message",group[1]);

group[1] = group 1 validation.. if the user selects a "yes" relating to group 1.. group 1's validation will be enabled

and i can have group[2] as well if i wish

wonder if this is actually too difficult to tackle.. it's a lot of work.. but perhaps you can point me to the right track?

Thanks JD!
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Hey andreni hows it going?

this is using your above code example and I think it is what you are after

At the bottom there are two new functions for adding primary and secondary validation. The primary validation is added when the page loads by calling add_Primary_Validation however the secondary is not.

Then when the user clicks an option in the Yes/No for a second card holder the function set_Validation is called.

This removes ALL validation then reapplies the primary validation and then if the user has clicked Yes it applies the secondary validation.

Give it a go and let me know, but it seems ok for me :)

<script>
var ORIGINAL_TEXT_COLOR = "black";
var ERROR_TEXT_COLOR = "white";


// Clears the all validations then adds back in the primary and if the user has selected yes, then adds in the secondary aswell
function set_Validation(obj_Sel){
  // Clear all validation
  frmvalidator.clearAllValidations();
  // Reapply primary validation
  add_Primary_Validation();

  // If the user selected yes then apply the secondary validation
  if(obj_Sel[obj_Sel.selectedIndex].value =="yes"){
    add_Secondary_Validation();
  }
}


function Validator(frmname){

   this.formobj=document.forms[frmname];
    if(!this.formobj)
    {
      alert("BUG: couldnot get Form object "+frmname);
         return;
    }
    if(this.formobj.onsubmit)
    {
     this.formobj.old_onsubmit = this.formobj.onsubmit;
     this.formobj.onsubmit=null;
    }
    else
    {
     this.formobj.old_onsubmit = null;
    }
    this.formobj.onsubmit=form_submit_handler;
    this.addValidation = add_validation;
    this.setAddnlValidationFunction=set_addnl_vfunction;
    this.clearAllValidations = clear_all_validations;
}

function set_addnl_vfunction(functionname)
{
 this.formobj.addnlvalidation = functionname;
}

function clear_all_validations()
{
    for(var itr=0;itr < this.formobj.elements.length;itr++)
    {
         this.formobj.elements[itr].validationset = null;
    }
}

var errMsg;

function form_submit_handler(){
    errMsg = "";
    var retVal = true;
    var firstFrmValidateFailedObj;

    for(var itr=0;itr < this.elements.length;itr++)
    {
         if(this.elements[itr].validationset &&

!this.elements[itr].validationset.validate())
         {
           retVal = false;
           if(typeof(firstFrmValidateFailedObj) == "undefined"){

                     firstFrmValidateFailedObj = this.elements[itr];
                }
         }
    }

   if(errMsg>""){
         alert("Please correct these errors:"+errMsg);
         if(typeof(firstFrmValidateFailedObj) != "undefined"){
             

firstFrmValidateFailedObj.style.color=ORIGINAL_TEXT_COLOR;
              if(firstFrmValidateFailedObj.type == "text" ||

firstFrmValidateFailedObj.type == "textarea"){
               firstFrmValidateFailedObj.select();
              }
          firstFrmValidateFailedObj.focus();
     }
     return false;
   } else {
     document.getElementById("Submit").disabled=true;
   }


   if(retVal && this.addnlvalidation){
      str =" var ret = "+this.addnlvalidation+"()";
      eval(str);
          if(retVal && !ret) return ret;
   }
   return retVal;
}


function add_validation(itemname,descriptor,errstr)
{
    if(!this.formobj)
    {
         alert("BUG: the form object is not set properly");
         return;
    }//if
    var itemobj = this.formobj[itemname];

   if(itemobj.length && isNaN(itemobj.selectedIndex) )
   //for radio button; don't do for 'select' item
    {
         itemobj = itemobj[0];
    }
     if(!itemobj)
    {
         alert("BUG: Couldnot get the input object named: "+itemname);
         return;
    }

     if(!itemobj.validationset)
    {
         itemobj.validationset = new ValidationSet(itemobj);
    }
    itemobj.validationset.add(descriptor,errstr);
}


function ValidationDesc(inputitem,desc,error)
{
   this.desc=desc;
    this.error=error;
    this.itemobj = inputitem;
    this.validate=vdesc_validate;
}


function vdesc_validate(){
  if(!this.itemobj.oldColor){
    this.itemobj.oldColor =

"color:"+this.itemobj.style.backgroundColor;
  }
  if(!validateInput(this.desc,this.itemobj,this.error)){
    this.itemobj.style.backgroundColor="red"
    this.itemobj.style.color=ERROR_TEXT_COLOR;
    this.itemobj.focus();
    this.itemobj.onkeydown =

function(){this.style.backgroundColor=this.oldColor.split("color:")[1

];this.style.color=ORIGINAL_TEXT_COLOR};
     this.itemobj.onclick = this.itemobj.onkeydown;
     return false;
  } else {
     

this.itemobj.style.backgroundColor=this.itemobj.oldColor.split("color:")[1];
     return true;
  }
}

function ValidationSet(inputitem)
{
   this.vSet=new Array();
    this.add= add_validationdesc;
    this.validate= vset_validate;
    this.itemobj = inputitem;
}
function add_validationdesc(desc,error)
{
 this.vSet[this.vSet.length]=
  new ValidationDesc(this.itemobj,desc,error);
}
function vset_validate()
{
   for(var itr=0;itr<this.vSet.length;itr++)
      {
        if(!this.vSet[itr].validate())
           {
             return false;
           }
      }
      return true;
}

/*  checks the validity of an email address entered
*   returns true or false
*/
function validateEmail(email)
{
   var splitted = email.match("^(.+)@(.+)$");
   if(splitted == null) return false;
   if(splitted[1] != null )
   {
     var regexp_user=/^\"?[\w-_\.]*\"?$/;
     if(splitted[1].match(regexp_user) == null) return false;
   }
   if(splitted[2] != null)
   {
     var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
     if(splitted[2].match(regexp_domain) == null)
      {
        var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
        if(splitted[2].match(regexp_ip) == null) return false;
     }// if
     return true;
   }
return false;
}

function

TestComparison(objValue,strCompareElement,strvalidator,strError)
{
  var bRet=true;
  var objCompare=null;
  if(!objValue.form)
  {
     alert("BUG: No Form object!");
      return false
  }
  objCompare = objValue.form.elements[strCompareElement];
  if(!objCompare)
  {
    alert("BUG: Element with name"+strCompareElement+" not found !");
    return false;
  }
  if(strvalidator != "eqelmnt" &&
         strvalidator != "neelmnt")
  {
     if(isNaN(objValue.value))
      {
        errMsg += "\n\t"+objValue.name+": Should be a number ";
        return false;
      }//if
      if(isNaN(objCompare.value))
      {
        errMsg += "\n\t"+objCompare.name+": Should be a number ";
        return false;
      }//if
  }//if
  var cmpstr="";
  switch(strvalidator)
  {
      case "eqelmnt":
               {
                 if(objValue.value != objCompare.value)
                 {
                      cmpstr = " should be equal to ";
                    bRet = false;
                 }//if
                 break;
              }//case
         case "ltelmnt":
              {
              if(eval(objValue.value) >= eval(objCompare.value))
                    {
                     cmpstr =  " should be less than ";
                      bRet = false;
                    }
                break;
              }//case
         case "leelmnt":
              {
                   if(eval(objValue.value) >  eval(objCompare.value))
                    {
                     cmpstr =  " should be less than or equal to";
                      bRet = false;
                    }
                break;
              }//case
         case "gtelmnt":
              {
                   if(eval(objValue.value) <=  

eval(objCompare.value))
                    {
                     cmpstr =  " should be greater than";
                      bRet = false;
                    }
                break;
              }//case
         case "geelmnt":
              {
                   if(eval(objValue.value) < eval(objCompare.value))
                    {
                     cmpstr =  " should be greater than or equal to";
                      bRet = false;
                    }
                break;
              }//case
         case "neelmnt":
              {
                 if(objValue.value.length > 0 &&
                   objCompare.value.length > 0 &&
                   objValue.value == objCompare.value)
                 {
                      cmpstr = " should be different from ";
                    bRet = false;
                 }//if
                 break;
               }
   }//switch
  if(bRet==false)
  {
     if(!strError || strError.length==0)
      {
        strError = objValue.name + cmpstr + objCompare.value;
       }//if
      errMsg += "\n\t"+strError;
  }//if
  return bRet;
}
function TestSelMin(objValue,strMinSel,strError)
{
   var bret = true;
    var objcheck = objValue.form.elements[objValue.name];
    var chkcount =0;
    if(objcheck.length)
    {
         for(var c=0;c < objcheck.length;c++)
         {
            if(objcheck[c].checked == "1")
            {
              chkcount++;
            }//if
         }//for
    }
    else
    {
      chkcount = (objcheck.checked == "1")?1:0;
    }
    var minsel = eval(strMinSel);
    if(chkcount < minsel)
    {
         if(!strError || strError.length ==0)
          {
               strError = "Please Select atleast"+minsel+" check boxes for"+objValue.name;
         }//if
          errMsg += "\n\t"+strError;
          bret = false;
    }
    return bret;
}

function TestDontSelectChk(objValue,chkValue,strError)
{
   var pass=true;
    var objcheck = objValue.form.elements[objValue.name];
   if(objcheck.length)
    {
         var idxchk=-1;
         for(var c=0;c < objcheck.length;c++)
         {
            if(objcheck[c].value == chkValue)
            {
              idxchk=c;
               break;
            }//if
         }//for
         if(idxchk>= 0)
         {
           if(objcheck[idxchk].checked=="1")
           {
             pass=false;
           }
         }//if
    }
    else
    {
         if(objValue.checked == "1")
         {
              pass=false;
         }//if
    }//else
    if(pass==false)
    {
    if(!strError || strError.length ==0)
        {
             strError = "Can't Proceed as you selected "+objValue.name;
       }//if
       errMsg += "\n\t"+strError;

     }
   return pass;
}

function TestRequiredInput(objValue,strError)
{
var ret = true;
   if(eval(objValue.value.length) == 0)
    {
       if(!strError || strError.length ==0)
       {
         strError = objValue.name + " : Required Field";
       }//if
       errMsg += "\n\t"+strError;
       ret=false;
    }//if
return ret;
}

function TestMaxLen(objValue,strMaxLen,strError)
{
var ret = true;
   if(eval(objValue.value.length) > eval(strMaxLen))
    {
      if(!strError || strError.length ==0)
      {
        strError = objValue.name + " : "+ strMaxLen +" characters maximum ";
      }//if
      errMsg += "\n\t"+strError + "\n\t[Current length = " +

objValue.value.length + "]";
      ret = false;
    }//if
return ret;
}

function TestMinLen(objValue,strMinLen,strError)
{
var ret = true;
   if(eval(objValue.value.length) <  eval(strMinLen))
    {
      if(!strError || strError.length ==0)
      {
        strError = objValue.name + " : " + strMinLen + " characters minimum  ";
      }//if
      errMsg += "\n\t"+strError + "\n\t[Current length = " + objValue.value.length + "]";
      ret = false;
    }//if
return ret;
}

function TestInputType(objValue,strRegExp,strError,strDefaultError)
{
  var ret = true;

   var charpos = objValue.value.search(strRegExp);
    if(objValue.value.length > 0 &&  charpos >= 0)
    {
     if(!strError || strError.length ==0)
      {
        strError = strDefaultError;
     }//if
      errMsg += "\n\t"+strError + "\n\t [Error character position " + eval(charpos+1)+"]";
      ret = false;
    }//if
 return ret;
}

function TestEmail(objValue,strError)
{
var ret = true;
    if(objValue.value.length > 0 && !validateEmail(objValue.value)    

  )
     {
       if(!strError || strError.length ==0)
       {
          strError = objValue.name+": Enter a valid Email address ";
       }//if
       errMsg += "\n\t"+strError;
       ret = false;
     }//if
return ret;
}

function TestLessThan(objValue,strLessThan,strError)
{
var ret = true;
      if(isNaN(objValue.value))
       {
         errMsg += "\n\t"+objValue.name+": Should be a number ";
         ret = false;
       }//if
       else
      if(eval(objValue.value) >=  eval(strLessThan))
       {
         if(!strError || strError.length ==0)
         {
           strError = objValue.name + " : value should be less than "+ strLessThan;
         }//if
         errMsg += "\n\t"+strError;
         ret = false;
        }//if
return ret;
}

function TestGreaterThan(objValue,strGreaterThan,strError)
{
var ret = true;
    if(isNaN(objValue.value))
     {
       errMsg += "\n\t"+objValue.name+": Should be a number ";
       ret = false;
     }//if
      else
    if(eval(objValue.value) <=  eval(strGreaterThan))
      {
        if(!strError || strError.length ==0)
        {
          strError = objValue.name + " : value should be greater than "+ strGreaterThan;
        }//if
        errMsg += "\n\t"+strError;
       ret = false;
     }//if
return ret;
}

function TestRegExp(objValue,strRegExp,strError)
{
var ret = true;
   if( objValue.value.length > 0 &&
        !objValue.value.match(strRegExp) )
    {
      if(!strError || strError.length ==0)
      {
        strError = objValue.name+": Invalid characters found ";
      }//if
      errMsg += "\n\t"+strError;
      ret = false;
    }//if
return ret;
}
function TestDontSelect(objValue,index,strError)
{
var ret = true;
    if(objValue.selectedIndex == null)
     {
       alert("BUG: dontselect command for non-select Item");
       ret = false;
     }
      else
    if(objValue.selectedIndex == eval(index))
     {
      if(!strError || strError.length ==0)
       {
       strError = objValue.name+": Please Select one option ";
       }//if
       errMsg += "\n\t"+strError;
       ret =  false;
      }
return ret;
}

function TestSelectOneRadio(objValue,strError)
{
    var objradio = objValue.form.elements[objValue.name];
    var one_selected=false;
    for(var r=0;r < objradio.length;r++)
    {
      if(objradio[r].checked == "1")
      {
           one_selected=true;
         break;
      }
    }
    if(false == one_selected)
    {
     if(!strError || strError.length ==0)
       {
        strError = "Please select one option from "+objValue.name;
       }
       errMsg += "\n\t"+strError;
    }
return one_selected;
}

//*  Checks each field in a form
function validateInput(strValidateStr,objValue,strError)
{
    var ret = true;
   var epos = strValidateStr.search("=");
    var  command  = "";
    var  cmdvalue = "";
    if(epos >= 0)
    {
     command  = strValidateStr.substring(0,epos);
     cmdvalue = strValidateStr.substr(epos+1);
    }
    else
    {
     command = strValidateStr;
    }

    switch(command)
    {
        case "req":
        case "required":
         {
             ret = TestRequiredInput(objValue,strError)
          break;
         }
       case "maxlength":
        case "maxlen":
          {
                ret = TestMaxLen(objValue,cmdvalue,strError)
            break;
          }
       case "minlength":
        case "minlen":
           {
                ret = TestMinLen(objValue,cmdvalue,strError)
            break;
           }
       case "alnum":
        case "alphanumeric":
           {
                    ret = TestInputType(objValue,"[^A-Za-z0-9]",strError,objValue.name+": Only alpha-numeric characters allowed ");
                   break;
           }
       case "alnum_s":
        case "alphanumeric_space":
           {
                    ret = TestInputType(objValue,"[^A-Za-z0-9\\s]",strError,objValue.name+": Only alpha-numeric characters and space allowed ");
                   break;
           }
        case "num":
        case "numeric":
           {
                ret = TestInputType(objValue,"[^0-9]",strError,objValue.name+": Only digits allowed ");
               break;
           }
       case "alphabetic":
        case "alpha":
           {
                ret = TestInputType(objValue,"[^A-Za-z]",strError,objValue.name+": Only alphabetic characters allowed ");
               break;
           }
       case "alphabetic_space":
        case "alpha_s":
           {
                ret = TestInputType(objValue,"[^A-Za-z\\s]",strError,objValue.name+": Only alphabetic characters and space allowed ");
               break;
           }
       case "email":
          {
                  ret = TestEmail(objValue,strError);
              break;
          }
       case "lt":
        case "lessthan":
         {
               ret = TestLessThan(objValue,cmdvalue,strError);
             break;
         }
       case "gt":
        case "greaterthan":
         {
               ret = TestGreaterThan(objValue,cmdvalue,strError);
           break;
         }
       case "regexp":
         {
               ret = TestRegExp(objValue,cmdvalue,strError);
          break;
         }
       case "dontselect":
         {
                ret = TestDontSelect(objValue,cmdvalue,strError)
            break;
         }
         case "dontselectchk":
         {
              ret = TestDontSelectChk(objValue,cmdvalue,strError)
              break;
         }
         case "selmin":
         {
              ret = TestSelMin(objValue,cmdvalue,strError);
              break;
         }
         case "selone":
         {
              ret = TestSelectOneRadio(objValue,strError);
             break;
         }
          //Comparisons
         case "eqelmnt":
          case "ltelmnt":
         case "leelmnt":
         case "gtelmnt":
         case "geelmnt":
         case "neelmnt":
         {
             return

TestComparison(objValue,cmdvalue,command,strError);
             break;
         }
   }//switch
    return ret;
}
</script>


<form name="myform">
Primary Cardholder information
<select name="name1">
<option>Mr
<option>Mrs
<option>Ms
</select>
First Name<input type=text name="name2">
Last Name<input type=text name="name3">
<br>
<input type=radio name="name4" value="One"> One
<input type=radio name="name4" value="Two"> Two
<input type=radio name="name4" value="Three"> Three
<br>
<input type=checkbox name="name5" value="One"> One
<input type=checkbox name="name5" value="Two"> Two
<input type=checkbox name="name5" value="Three"> Three

<br>
<br>
would you like to add another card holder?
<select name="test" id="test" onChange="set_Validation(this);">
<option value="">select</option>
<option value="yes">yes</option>
<option value="no">no</option>
</select>
<br>
Enter secondary cardholder information:<br>
First Name: <input type="text" name="second_fname">
Last Name: <input type="text" name="second_lname">

<br><br>
<input type=submit>
</form>

<!-- This is where the validation commands are -->

<SCRIPT language=JavaScript type="text/javascript">
 var frmvalidator  = new Validator("myform");
 add_Primary_Validation();
function add_Primary_Validation() {
<!-- for select list form, uses "dontselect=0" -->
 frmvalidator.addValidation("name1","dontselect=0","Select list error message");
<!-- "req" is for required entry for inputbox -->
 frmvalidator.addValidation("name2","req","inputbox error message");
<!-- "minlen=#" is minimum length requirement -->
 frmvalidator.addValidation("name3","minlen=3", "inputbox minimum length error message");
<!-- "selone" is for radio box requirement selection -->
 frmvalidator.addValidation("name4","selone","Radio box error message");
<!-- "selmin" is for checkbox requirement -->
 frmvalidator.addValidation("name5","selmin=1","checkbox error message");
}

function add_Secondary_Validation() {

<!-- "req" is for required entry for inputbox -->
 frmvalidator.addValidation("second_fname","req","You must enter the second first name");
<!-- "minlen=#" is minimum length requirement -->
 frmvalidator.addValidation("second_lname","minlen=3", "inputbox minimum length error message");

}
</script>


Cheers

Scott
0
 

Author Comment

by:andreni78
Comment Utility
Scott! my man.. you are awesome.. your code works.. but i was looking for something that allows me to add a 3rd group of validation as well..  (perhaps something that can take as many groups of validations as one wishes?) - but all i really need is 3.. can you make it so that the a group of validation would be activated by the toggle function?
http://majestic.gotdns.com/capture.html

like the "free download" button would activate/deactivate the group of validations...

thanks Scott!

0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Hi andreni

basically with what I have done you can have as many validation sets as you like for example

add_Primary_Validation
add_Secondary_Validation
add_Tertiary_Validation
add_Fourth_Validation
add_Fifth_Validation
.
.
.

Then wherever on the form you have an action that might change the validation for the form you would call set_Validation first.

In doing this you call clearAllValidations(); which removes all items from the validator(I couldnt see a removeValidation function so this seemed like the best way). Then based on the options currently selected on the form you would call the correct combination of the above functions which adds back in the correct validations.

Not sure what you mean by the toggle function? can't see one on http://majestic.gotdns.com/capture.html

let me know

Cheers

Scott
0
 

Author Comment

by:andreni78
Comment Utility
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
That looks familiar :)

so do you want two validation groups

one for each form

then depending on which one is displayed, controls which validation is active?

Scott
0
 

Author Comment

by:andreni78
Comment Utility
I understand your
add_Primary_Validation
add_Secondary_Validation
add_Tertiary_Validation
add_Fourth_Validation
add_Fifth_Validation
.
.
.
concept..

i just want to be able to use the toggle method instead of the select list if i wanted to
so u've got the select list method nailed:
  if(obj_Sel[obj_Sel.selectedIndex].value =="yes"){
    add_Secondary_Validation();
  }

i just need a toggle method:
if toggle is clicked {
add_Tertiary_Validation();
}

so the toggle method would toggle the validation as well =)

btw the alert window shows at the bottom right.. is that right? how do i center it?
0
 

Author Comment

by:andreni78
Comment Utility
nm about the bottom right alert.. i think it's just my comp
0
 

Author Comment

by:andreni78
Comment Utility
actually that request is another project.. i'll post it.. great work once again Scott
0
 
LVL 15

Accepted Solution

by:
Colosseo earned 500 total points
Comment Utility
Ah i get you now

using methodc it would just be a case of modifying the toggle function to include a clear of all the validations and then reapply them based on:

If the user has made an option in the select
if d has been chosen then add primary validation <--- adds new validation
if secondary form already displayed then reapply secondary validation <--- keeps existing validation in place

If the user has toggled the button
if the secondary form has been displayed then add secondary validation <--- adds new validation
if d is already selected in the drop down then reapply primary validation <--- keeps existing validation in place

Does that seem like what you mean?

Cheers

Scott
0
 

Author Comment

by:andreni78
Comment Utility
Yeah I think you got it.. my real form is like this..

http://majestic.gotdns.com/methodc.htm

(Area A) validations will always exist..

then

(AREA B)
If the user has made an option in the select
if d has been chosen then add secondary validation <--- adds new validation
if tertiary form already displayed then reapply tertiary validation <--- keeps existing validation in place

(AREA C)
If the user has toggled the button
if the tertiary form has been displayed then add tertiary validation <--- adds new validation
if d is already selected in the drop down then reapply secondary validation <--- keeps existing validation in place

Hope this clears things up
0
 

Author Comment

by:andreni78
Comment Utility
remember to use your above code.. the code on methodc.htm page isn't updated... just example
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
so

should i get the toggle working on this page?

http://majestic.gotdns.com/methodc.htm

or another?

Scott
0
 

Author Comment

by:andreni78
Comment Utility
ok I've updated the page with your new group validation script.. the drop down menu works beautifully.. just the toggle now =)   great work Scott!!!!

http://majestic.gotdns.com/methodc.htm
0
 

Author Comment

by:andreni78
Comment Utility
i'm thinking about using select menu only because that'll make the script less confusing/complex

this is Method D

http://majestic.gotdns.com/methodd.htm

if you play around w/ the Area B and Area C validations.. you'll see that there are some logical problems...
0
 

Author Comment

by:andreni78
Comment Utility
just wondering if you could help me out on this section Scott

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21114559.html
0
 
LVL 15

Expert Comment

by:Colosseo
Comment Utility
Hi andreni

thanks for the grade  sorry i have been in hospital for a few days :)

I will have a look at

http://www.experts-exchange.com/Web/Web_Languages/JavaScript/Q_21114559.html

tomorrow if it hasnt already been answered... cheers

Scott
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now