jeudi 22 octobre 2015

If a or b = null or no value then... Filling in last field overrides function?

I have this code:

if(document.getElementById('UserType_2').checked)
    {if(a==null || a=="",b==null || b=="",c==null || c=="",d==null || d=="",k==null || k=="",e==null || e=="",g==null || g=="",h==null || h=="",j==null || j=="",k==null || k=="")
    {document.forms["619new"]["next1"].disabled = true;
    document.forms["619new"]["next1"].style.background='#FDFDFD';
    document.forms["619new"]["next1"].style.color = 'lightgray';
        document.forms["619new"]["next1"].style.border = 'none';
        document.forms["619new"]["next1"].style.cursor = 'not-allowed';}
    else{document.forms["619new"]["next1"].disabled = false;
    document.forms["619new"]["next1"].style.background='#195dad';
    document.forms["619new"]["next1"].style.color = 'lightgray';
        document.forms["619new"]["next1"].style.border = 'none';
        document.forms["619new"]["next1"].style.cursor = 'pointer';}
    }

It is meant to disable a button unless the fields are entered. Once entered button becomes clickable.

This works. HOWEVER... If i decide to fill the last field in first it overrides all the other fields and unlocks the button when the others are empty.

I have tried to find a fix but have become stuck. Can anyone help?

Thanks

Phil

Aucun commentaire:

Enregistrer un commentaire