Credit Card Validate Rules

4 posts, 0 answers
  1. Tony
    Tony avatar
    33 posts
    Member since:
    Dec 2011

    Posted 24 Feb 2012 Link to this post

    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
  2. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 27 Feb 2012 Link to this post

    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!
  3. Kendo UI is VS 2017 Ready
  4. Vesselin Obreshkov
    Vesselin Obreshkov avatar
    81 posts
    Member since:
    Jan 2010

    Posted 29 Feb 2012 Link to this post

    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? 
  5. Rosen
    Admin
    Rosen avatar
    3237 posts

    Posted 01 Mar 2012 Link to this post

    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!
Back to Top
Kendo UI is VS 2017 Ready