Bin e padrões para validação de cartão de crédito.
Bandeira | Começa com | Máximo de número | Máximo de número cvc |
---|---|---|---|
Visa | 4 | 13,16 | 3 |
Mastercard | 5 | 16 | 3 |
/// ASP.NET MVC 3 Credit Card Validator Attribute | |
/// by Ben Cull - 4 November 2010 | |
/// | |
/// With special thanks to: | |
/// Thomas @ Orb of Knowledge - http://orb-of-knowledge.blogspot.com/2009/08/extremely-fast-luhn-function-for-c.html | |
/// For the Extremely fast Luhn algorithm implementation | |
/// | |
/// And Paul Ingles - http://www.codeproject.com/KB/validation/creditcardvalidator.aspx | |
/// For a timeless blog post on credit card validation |
/// <summary> | |
/// Validação customizada para CPF | |
/// </summary> | |
public class CustomValidationCPFAttribute : ValidationAttribute, IClientValidatable | |
{ | |
/// <summary> | |
/// Construtor | |
/// </summary> | |
public CustomValidationCPFAttribute() { } |
<!DOCTYPE html> | |
<html ng-app="app"> | |
<head> | |
<title></title> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.7/jquery.min.js"></script> | |
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.7/angular.js"></script> | |
<style> | |
.hide { | |
display: none; |
// Generates a URL-friendly "slug" from a provided string. | |
// For example: "This Is Great!!!" transforms into "this-is-great" | |
function generateSlug (value) { | |
// 1) convert to lowercase | |
// 2) remove dashes and pluses | |
// 3) replace spaces with dashes | |
// 4) remove everything but alphanumeric characters and dashes | |
return value.toLowerCase().replace(/-+/g, '').replace(/\s+/g, '-').replace(/[^a-z0-9-]/g, ''); | |
}; |
/** | |
* Create a web friendly URL slug from a string. | |
* | |
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support. | |
* | |
* Although supported, transliteration is discouraged because | |
* 1) most web browsers support UTF-8 characters in URLs | |
* 2) transliteration causes a loss of information | |
* | |
* @author Sean Murphy <sean@iamseanmurphy.com> |
public static class QuerableExtensions | |
{ | |
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property, bool asc) | |
{ | |
return ApplyOrder<T>(source, property, asc ? "OrderBy" : "OrderByDescending"); | |
} | |
public static IOrderedQueryable<T> OrderBy<T>(this IQueryable<T> source, string property) | |
{ | |
return ApplyOrder<T>(source, property, "OrderBy"); | |
} |
using System.Security.Cryptography; | |
/// Hashes an email with MD5. Suitable for use with Gravatar profile | |
/// image urls | |
public static string HashEmailForGravatar(string email) | |
{ | |
// Create a new instance of the MD5CryptoServiceProvider object. | |
MD5 md5Hasher = MD5.Create(); | |
// Convert the input string to a byte array and compute the hash. |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Linq.Expressions; | |
using System.Web; | |
namespace System.Web.Mvc.Html | |
{ | |
public static class HH |