javascript - validation for two select box using array -
i have array 'a' this
var = new array(); a[key] =a[value]; a['mpp']='mpp'; a['pdf']='pdf'; a['excel']='xls'; a['word']='doc'; a['ppt']='ppt'; a['html']='html';
i have 2 select box 1 docformat contains a[key] , extension contains a[value], on submit have validate 2 select box array , can please suggest help?
one way using jquery
function validate(){ var key = $("#select-key").val(), val = $("#select-value").val(); return key in && a[key] == val; }
assuming a
array , select boxes have ids select-key
, select-value
respectively.
hope helps.
Comments
Post a Comment