PDA

View Full Version : Validation in javascript



Dimi Cost
04-11-2011, 10:23 AM
I must validate a textbox that is an input for credit card.I try and find this code.I would like your opinion.Thanks.

<script>


function validate()
{
var cardexp=/^\d{4}\s{0,}\d{4}\s{0,}\d{4}\s{0,}\d{4}$/


if (!cardexp.test(document.frmname.fldname.value))
{
document.number.fldname.value="Please enter your credit card number";
document.number.fldname.focus();
return false
}

}

</script>
<input type="text" size="10" maxlength="9" name="number" value="" onmouseout="return Validate()"/>

Nile
04-11-2011, 11:42 AM
Try this: http://www.evolt.org/node/24700