Skip to content

Instantly share code, notes, and snippets.

@leandrocustodio
leandrocustodio / Aplicacao.js
Last active October 7, 2018 21:29
Extensão Jquery Validate. Validar data no formato dd/mm/aaaa
/*Aplicando a validação*/
$(".boxFormCadastro form").validate({
errorLabelContainer: "#messageBox",
rules: {
dataNascimento: {
required: true,
dateBR: true
}
},
messages: {
@guisehn
guisehn / gist:3276302
Last active February 9, 2025 01:48
Validar CNPJ (PHP)
<?php
function validar_cnpj($cnpj)
{
$cnpj = preg_replace('/[^0-9]/', '', (string) $cnpj);
// Valida tamanho
if (strlen($cnpj) != 14)
return false;
@vrushank-snippets
vrushank-snippets / Convert strings to slugs
Created March 23, 2012 11:03
PHP : Convert strings to slugs
function slug($str){
$str = strtolower(trim($str));
$str = preg_replace('/[^a-z0-9-]/', '-', $str);
$str = preg_replace('/-+/', "-", $str);
return $str;
}
@hallettj
hallettj / global-variables-are-bad.js
Created February 14, 2009 21:15
How and why to avoid global variables in JavaScript
// It is important to declare your variables.
(function() {
var foo = 'Hello, world!';
print(foo); //=> Hello, world!
})();
// Because if you don't, the become global variables.
(function() {