custom code
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #433465
    Kristina
    Guest

    Hello! I need to connect validation via custom code. But when connecting, even with the correct value of the field, the validation gives an error. Please help to understand the reason.

    `function iinCheck(iin, clientType, birthDate, sex, isResident) {
    isResident = isResident || true;
    if(!iin) return false;
    if(iin.length!=12) return false;
    if(!(/[0-9]{12}/.test(iin))) return false;
    switch(clientType){
    case 1:
    if(iin.substring(0, 6)!=(
    “” +
    (birthDate.getYear()) +
    ((birthDate.getMonth()+1)<10?”0″:””)+
    (birthDate.getMonth()+1)+
    (birthDate.getDate()<10?”0″:””)+
    birthDate.getDate())) return false;
    var s = parseInt(iin.substring(6, 7));
    if(((s%2)==1)!=sex) return false;
    if(
    birthDate.getFullYear()<(1800+parseInt(s/2)*100)
    || birthDate.getFullYear()>(1900+parseInt(s/2)*100)) return false;
    break;
    case 2:
    var m = parseInt(iin.substring(2, 4));
    if(m>12) return false;
    var r = parseInt(iin.substring(4, 5));
    if(r<4 || r>6 || (r==4 && !isResident) || (r==5 && isResident)) return false;
    break;
    }
    var b1 = [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 ];
    var b2 = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 1, 2 ];
    var a = [];
    var controll = 0;
    for(var i=0; i<12; i++){
    a[i] = parseInt(iin.substring(i, i+1));
    if(i<11) controll += a[i]*b1[i];
    }
    controll = controll % 11;
    if(controll==10) {
    alert(“s”);
    controll = 0;
    for(var i=0; i<11; i++)
    controll += a[i]*b2[i];
    controll = controll % 11;
    }
    if(controll!=a[11]) return false;
    return true;
    }

    #433678
    Dinesh
    Keymaster

    Hi,

    I think you got wrong about custom code here. Custom code function is where you can add predefined list of codes and then those codes can be validated while user enter those codes.

    Hope this clears.

    Thanks

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘custom code’ is closed to new replies.