Skip to content

Instantly share code, notes, and snippets.

View srttk's full-sized avatar
🏡
WFH

Sarath srttk

🏡
WFH
View GitHub Profile
//http://jqueryvalidation.org/
<script type="text/javascript" src="js/jquery.validate.min.js">
</script>
<script type="text/javascript">
$(document).ready(function()
{
//form validation rules
// alert('Hello');
$("#careersForm").validate({
@srttk
srttk / gist:6037416
Created July 19, 2013 07:43
PHP_Filter_validation
//Email validation
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
$error="Invalid email addrress";
}
//
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule .* index.php/$0 [PT,L]
@srttk
srttk / gist:9285385
Created March 1, 2014 04:52
jQuery add validation rule dynamically
function reqty_validation(){
if($("#required_qty").val()!="")
{
$("#required_qty_unit").rules('add',{required:true});
}
}
@srttk
srttk / gist:e62f942f97f01272820f
Created March 25, 2015 05:25
Browser geolocation
function initGeolocation()
{
history.replaceState({}, "Title", "http://somedomian.dddssdsd/send.php");
if( navigator.geolocation )
{
// Call getCurrentPosition with success and failure callbacks
navigator.geolocation.getCurrentPosition(success,fail);
}
else
{
@srttk
srttk / function_invocation.js
Created April 3, 2017 13:05 — forked from myshov/function_invocation.js
11 Ways to Invoke a Function
console.log(1);
(_ => console.log(2))();
eval('console.log(3);');
console.log.call(null, 4);
console.log.apply(null, [5]);
new Function('console.log(6)')();
Reflect.apply(console.log, null, [7])
Reflect.construct(function(){console.log(8)}, []);
Function.prototype.apply.call(console.log, null, [9]);
Function.prototype.call.call(console.log, null, 10);
@srttk
srttk / array_chunk.js
Created April 7, 2017 02:54
Array chunk function
/*
chunk array elements
*/
function chunckArray(arr,chunkSize) {
return arr.map( function(e,i){
return i%chunkSize===0 ? arr.slice(i,i+chunkSize) : null;
})
.filter(function(e){ return e; });
@srttk
srttk / person.model.ts
Created May 23, 2017 11:31
Type script / ES 2015 class with propery fill method
export class Person {
name : string;
age: number;
fillFromJson(json: any) {
for (var propName in json) {
this[propName] = json[propName]
}
@srttk
srttk / some.model.ts
Created May 23, 2017 11:43
get set typescript properties
// Format conversions
get _startDate() {
if (this.startDate) {
let d = new Date(this.startDate);
return d.toLocaleDateString();
}
return '';
@srttk
srttk / ng-form-validation.html
Created May 25, 2017 06:08
Angular 2 / 4 Form validation
<form #heroForm="ngForm" *ngIf="active" (ngSubmit)="onSubmit()">
<div class="form-group">
<label for="name">Name</label>
<input type="text" id="name" class="form-control"
required minlength="4" maxlength="24"
name="name" [(ngModel)]="hero.name"
#name="ngModel" >
<div *ngIf="name.errors && (name.dirty || name.touched)"
class="alert alert-danger">
<div [hidden]="!name.errors.required">