|
Javascript form Validation help!!
Hi There
I'm after some help, I am tyring to change some code (in the absence of the developer) which we already have in place on one of our web forms.
However i am having some issues., mainly because i am unfamiliar with javascript and would really appreciate some help
I would really appreciate some help in changing the code below to Hide the sales consultant field unless 'SME Business Sales Lead' has been selected from the lead type feild:
var leadType = "" // global variable to indicate if the Lead Type is "direct" or "indirect"
function checkSalesConsultant() { // if they choose an 'indirect' lead then disable the Sales Consultant drop-down
var q = document.frmDetails.leadType;
var x = q.selectedIndex;
if (q[q.selectedIndex].innerText.match(/indirect/i))
{
document.frmDetails('00N20000001YpHI').selectedInd ex=0
document.frmDetails('00N20000001YpHI').disabled=tr ue
leadType = "indirect"
}
else
{
document.frmDetails('00N20000001YpHI').disabled=fa lse
leadType = "direct"
}
}
Secondly would like to prevent the validation shown below from running should 'Mid Market Lead' be selected from the leadType field referenced above:
// mpan validation
var mpanError = false
var mpan = q('00N20000001Y1SD').value
if (mpan.length != 13) {mpanError = true}
if ( isNaN(mpan) ) {mpanError = true}
var multiplier = new Array (3, 5, 7, 13, 17, 19, 23, 29, 31, 37, 41, 43)
var total = 0
var i
var needMPAN = false
if ( q('00N20000001Yius')[1].checked || q('00N20000001Yius')[2].checked ) {needMPAN = true}
for (i=0; i<12; i++) {total += mpan.substr(i,1) * multiplier[i]}
if ( total % 11 % 10 != mpan.substr(12,1) ) {mpanError = true}
if ( mpan.match(/0{13}/) ) {mpanError = true}
if (needMPAN && mpanError) {
ErrorMessage += '- the MPAN is invalid\n';
q('00N20000001Y1SD').style.backgroundColor='salmon ' }
Thanks in advance, thats greatley appreciated!
|