Everyone knows that a credit card number is normally made up of 12-16 numbers.However there are many ways that people type their number into a form, often including spaces or hyphens to break up the number and make it more readable.When you play around with the function, you’ll notice that the validation function is only called when the focus leaves the field, so you have to click outside of the field to actually make that error message pop up.
It receives a document element id regarding the place in my html code where I want to write the file size. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
The member ‘rc’ (or return code) is used to communicate back if the validation was successful or not.
In the latter case, we set rc to false, and also display an error message.
Listing 3: Validation for all letters Figure 3: Above output checks the entered data is letters or include any other char also. Two of them are using regular expression for matching and the other one is simple so not writing regex but if you want you can write a regex for this case also.