help, i have form with multiple combobox, i want add validation for submition selected combobox, this my form.. http://pastebin.com/k8r5Rnw4 at form have tabel SPh, CYL, Axis, i want to add validation for tabel SPH, CYL, AXIS, for this role..
SPH- CYL-AXIS
None - None - None... allow submit form
value - value - value ... allow submit
value - none - none ... allow submit
value - value - none ... cannot submit
Firstly, not to split hairs, but you don't have multiple comboboxes; if you are using the combobox library, you have multiple SELECT tags that use the combobox library - if you don't use the combobox library, you just have multiple SELECT tags (sometimes aka "drop-downs").
Assuming that the labels are the IDs (not name) of the SELECT tags (and you didn't give the FORM id, so I'm giving it an arbitrary id)..
Code:
function validateForm(){
var formObj = document.forms["thisForm"];
if((formObj.SPh.selectedIndex > 0) &&
(formObj.CYL.selectedIndex > 0) &&
(formObj.Axis.selectedIndex == 0)){
alert("Form cannot submit like this"); return false;
}
}
__________________ ^_^
If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
* The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
id combo is a, aa, aaa,aaaa,.... see my form at http://pastebin.com/k8r5Rnw4 my validation by value="0" but I want to add another validation for combo a ,aa,aaa,aaa.. the validation is cannot submit form before selecting first combo.... please help...
function validasi() { if(document.getElementById("xxx2").checked) { alert("Maaf, untuk pemesanan product dengan ukuran Anda silahkan menghubungi customer support via live chat, SMS, atau BBM "); return false; //batalkan submit, radio ke-2 yg di pilih }
if(document.getElementById("a").value=="0") { alert("Maaf, untuk pemesanan product dengan ukuran Anda silahkan menghubungi customer support via live chat, SMS, atau BBM "); return false; //batalkan submit, opsi 'a' belum dipilih }
if(document.getElementById("aa").value=="0") { alert("Maaf, untuk pemesanan product dengan ukuran Anda silahkan menghubungi customer support via live chat, SMS, atau BBM"); return false; //batalkan submit, opsi 'aa' belum dipilih }
if(document.getElementById("aaa").value=="0") { alert("Maaf, untuk pemesanan product dengan ukuran Anda silahkan menghubungi customer support via live chat, SMS, atau BBM"); return false; //batalkan submit, opsi 'aaa' belum dipilih } if(document.getElementById("aaaa").value=="0") { alert("Maaf salah"); return false; //batalkan submit, opsi 'aaa' belum dipilih }
if(document.getElementById("aaaaa").value=="0") { alert("Maaf, untuk pemesanan product dengan ukuran Anda silahkan menghubungi customer support via live chat, SMS, atau BBM "); return false; //batalkan submit, opsi 'aaa' belum dipilih }
how to add validation, if "a" is selected then have to selected "aa" if "aa" selected then have to selected "aaa"... -> not allow select next dropdown before selected first dropdown..
As your post is partly in a foreign language, I am not sure that I completely understand what you want, but if you have three select lists you can obtain the selected indices of all three with:-
Code:
var val1 = document.getElementById("a").selectedIndex;
var val2 = document.getElementById("aa").selectedIndex;
var val3 = document.getElementById("aaa").selectedIndex;
and then use if..else statements to identify combinations where submission is not allowed:-