This is a migrated thread and some comments may be shown as answers.

Credit Card Validate Rules

3 Answers 321 Views
Validation
This is a migrated thread and some comments may be shown as answers.
Tony
Top achievements
Rank 1
Tony asked on 24 Feb 2012, 05:15 PM
Hi,

Is there a credit card validation rule built into the validator? I can't seem to find any reference to credit card validation in the docs or examples.

I have a checkout form I'd like to use some widgets on but don't want to have to add jquery validate in addition to the kendo ui script.

If it doesn't existing please consider this a formal feature request.

Thanks.

Tony

3 Answers, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 27 Feb 2012, 08:43 AM
Hello Tony,

Indeed, there is no built-in credit card validation rule. However, such can be achieve either by using the built-in pattern validation rule, if a simple regular expression is sufficient , or by using a custom validation rule for more complex implementation. Here is an example using custom validation rule:



Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Vesselin Obreshkov
Top achievements
Rank 2
answered on 01 Mar 2012, 12:16 AM
Hey Rosen,

Is it possible to place our custom validation rules in a separate file that we can include as needed (much like jquery.validate.js has additional-methods.js). I tried this but it won't do anything (or I'm too tired and need to get off the computer):

JSFiddle Example

P.S. How do you embed your fiddles in a forum post? 
0
Rosen
Telerik team
answered on 01 Mar 2012, 09:46 AM
Hello Vesselin,

It will work, however you are assigning the result of the function's execution instead of the function itself. Thus:

//this
 rules: {
    creditcard: validateCreditCard(input)
},
//should be
rules: {
    creditcard: validateCreditCard
},


Regards,
Rosen
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Validation
Asked by
Tony
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Vesselin Obreshkov
Top achievements
Rank 2
Share this question
or