Hey all,
I would like to create a javascript function called checkCCField(). This function should check the credit card # that is placed in a text field called displaydigits and see if there are exactly 8 asterisks (*) in it. If there is not, then change the value of a hidden field called daccount to the one in the text field. If there does turn out to be 8 asterisks in the text field, do nothing.
The biggest problem I am having is how to declare and use my regular expression in my javascript code. The code would probably look something like the following:
Any feedback would be appreciated on this topic. Since I also do not have experience with js, if there is anything wrong with the logic
of the code above, I would appreciate checking into that too. Thanks in advance.
I would like to create a javascript function called checkCCField(). This function should check the credit card # that is placed in a text field called displaydigits and see if there are exactly 8 asterisks (*) in it. If there is not, then change the value of a hidden field called daccount to the one in the text field. If there does turn out to be 8 asterisks in the text field, do nothing.
The biggest problem I am having is how to declare and use my regular expression in my javascript code. The code would probably look something like the following:
Code:
// bookingSearch is my form name
// displaydigits is my text field in which I want to check for the credit card account
// display digits is the hidden field value that I want to change is I cannot match the Regex pattern
function checkCCField()
{
if(document.bookingSearch.displaydigits <not matching> <insert Regex pattern here for 8 asterisks??>)
{
document.bookingSearch.daccount.value = document.bookingSearch.displaydigits;
}
}
Any feedback would be appreciated on this topic. Since I also do not have experience with js, if there is anything wrong with the logic
of the code above, I would appreciate checking into that too. Thanks in advance.