JavaScript: Age Validation Form

Published on

This form validates the date selected by the user is valid and that the user is at least the age of 18. (Note that it does not dynamically adjust the day select list based on the month and year selected.) HTML <form id=”age-validation-form” class=”form-inline” method=”POST”> <div class=”form-group”> <select name=”dob_month” id=”dob_month” class=”required form-control”> <option value=””>Month</option> <option … Continue reading JavaScript: Age Validation Form

JavaScript: Age Validator

Published on

function isOfAge(year, month, day, age) { age = age || 18; var mydate = new Date(); mydate.setFullYear(year, month-1, day); var currdate = new Date(); currdate.setFullYear(currdate.getFullYear() – age); if ((currdate – mydate) < 0) { return false; } return true; } References: Validate Age | CSS-Tricks

JavaScript: Image onerror Fallback

Published on

Without a JavaScript function <img src=”image.png” onError=”this.onerror=null;this.src=’/images/noimage.gif’;” /> or With a JavaScript function function imgError(image) { image.onerror = “”; image.src = “/images/noimage.gif”; return true; } <img src=”image.png” onerror=”imgError(this);”/> For a compatibility lists of browsers that support the error facility: http://www.quirksmode.org/dom/events/error.html

Nginx Symfony2 Server Configuration

Published on

server { listen 80; #listen [::]:80 default_server ipv6only=on;root /usr/share/nginx/html; #index index.php index.html index.htm; server_name DOMAIN_NAME; root /var/www/SITE_DIRECTORY/web; # strip app.php/ prefix if it is present rewrite ^/app_dev\.php/?(.*)$ /$1 permanent; client_max_body_size 50m; location / { index app_dev.php; try_files $uri @rewriteapp; } location @rewriteapp { rewrite ^(.*)$ /app_dev.php/$1 last; } # pass the PHP scripts to FastCGI … Continue reading Nginx Symfony2 Server Configuration

Nginx Server Configuration on Ubuntu 14.04

Published on

server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;root /var/www/SITE_DIRECTORY/html; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name DOMAIN_NAME; client_max_body_size 50m; location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi … Continue reading Nginx Server Configuration on Ubuntu 14.04

Nginx Server Configuration for WordPress on Ubuntu 14.04

Published on

server { listen 80 #listen 80 default_server; #listen [::]:80 default_server ipv6only=on; root /var/www/WORDPRESS_DIRECTORY; index index.php index.html index.htm; # Make site accessible from http://localhost/ server_name WORDPRESS_DOMAIN; client_max_body_size 50m; location / { # try_files $uri $uri/ =404; try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page … Continue reading Nginx Server Configuration for WordPress on Ubuntu 14.04

Apache 2.4 Laravel Server Configuration

Published on

<VirtualHost *:80> ServerAdmin webmaster@PROJECT_NAME.com DocumentRoot /var/www/PROJECT_NAME/public/ ServerName PROJECT_DOMAIN <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/PROJECT_NAME/public/> Options Indexes FollowSymLinks MultiViews AllowOverride All Require all granted Allow from all </Directory> #ErrorDocument 404 / ErrorLog ${APACHE_LOG_DIR}/PROJECT_NAME_error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog ${APACHE_LOG_DIR}/PROJECT_NAME_access.log combined </VirtualHost> <IfModule … Continue reading Apache 2.4 Laravel Server Configuration

JavaScript: stripTags

Published on

/* Strip html tags. reference: http://davidwalsh.name/essential-javascript-functions */ function stripTags(htmlstr) { var div = document.createElement(‘div’); div.innerHTML = htmlstr; return div.textContent; }