Skip to content

Instantly share code, notes, and snippets.

View harishkotra's full-sized avatar
🏠
Working from home

Harish Kotra harishkotra

🏠
Working from home
View GitHub Profile
@harishkotra
harishkotra / gist:89a5f00f830ac3aefe1103ab8b8884e1
Created March 19, 2017 04:35
Ionic 1 directive to disable special characters in an input field
.directive('noSpecialChar', function() {
return {
require: 'ngModel',
restrict: 'A',
link: function(scope, element, attrs, modelCtrl) {
modelCtrl.$parsers.push(function(inputValue) {
if (inputValue == null)
return ''
cleanInputValue = inputValue.replace(/[^\w\s]/gi, '');
if (cleanInputValue != inputValue) {