Skip to content

Instantly share code, notes, and snippets.

View IsaacAndres's full-sized avatar

Isaac Calavera IsaacAndres

View GitHub Profile
public function phpRule_ValidarRut($rut) {
// Verifica que no esté vacio y que el string sea de tamaño mayor a 3 carácteres(1-9)
if ((empty($rut)) || strlen($rut) < 3) {
return array('error' => true, 'msj' => 'RUT vacío o con menos de 3 caracteres.');
}
// Quitar los últimos 2 valores (el guión y el dígito verificador) y luego verificar que sólo sea
// numérico
$parteNumerica = str_replace(substr($rut, -2, 2), '', $rut);
@JeffreyWay
JeffreyWay / laravel.js
Last active October 9, 2024 03:43
Want to send a DELETE request when outside of a form? This will handle the form-creation bits for you dynamically, similar to the Rails implementation. (Requires jQuery, but doesn't have to.) To use, import script, and create a link with the `data-method="DELETE"` attribute.
/*
<a href="posts/2" data-method="delete"> <---- We want to send an HTTP DELETE request
- Or, request confirmation in the process -
<a href="posts/2" data-method="delete" data-confirm="Are you sure?">
*/
(function() {