var msg = new Array();
msg [0] = 'Credit Card number is invalid';
msg [1] = 'Card holders name is required';
id like the relevant message to come up when my form is submitted. Form example:
<form id="PaymentForm" name="PaymentForm" method="post" action="#" class="big_box background border_solid">
<input type="text" name="CardNumber" id="CardNumber" size="25" maxlength="25" />
<span id="CardNumberMessage" style="display:none;color:red">&l开发者_运维知识库t;xsl:text> </xsl:text>*</span>
<div id="FieldsRequired"></div>
<input name="submitbutton" id="submitbutton" type="submit" />
</form>
so when the first field, in this case CardNumber is incorrect an * is placed next to the field and a message comes up next to the submit in the FieldsRequired div is saying whats in the Array msg[0]. I have two functions that show or hide the spans.
function showStuff(id,msg) {
document.getElementById(id).style.display = '';
document.getElementById(FieldsRequired).value;<!--this part might be wrong-->
};
function hideStuff(id,msg) {
document.getElementById(id).style.display = 'none';
document.getElementById(FieldsRequired).value;
};
any help would be great.
Since FieldsRequired is a div, you should use innerHTML futhermore FieldsRequired is not a variable name but an div identifier :
document.getElementById('FieldsRequired').innerHTML='your message'
You are not assigning any value
document.getElementById(FieldsRequired).value=msg[1];
精彩评论