-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathPersianDocumentNumberInputFix.min.js
More file actions
7 lines (6 loc) · 1.06 KB
/
PersianDocumentNumberInputFix.min.js
File metadata and controls
7 lines (6 loc) · 1.06 KB
1
2
3
4
5
6
7
/**
PersianDocumentNumberInputFix v0.9 is released under the MIT License <http://www.opensource.org/licenses/mit-license.php> by narmand.com
Lastest version can be found at https://github.com/arashmilani/PersianDocumentNumberInputFix
*/
var PersianDocumentNumberInputFix={Apply:function(c){$(c).css("direction","ltr").css("text-align","left");$(c).keydown(function(a){var b=$(this).val();switch(a.which){case 8:if(0===b.length)return!0;a=b[b.length-1].charCodeAt(0);1775<a&&1786>a?$(this).val(b.substr(0,b.length-2)):$(this).val(b.substr(0,b.length-1));return!1;default:if(47<a.which&&58>a.which)return $(this).val(b+String.fromCharCode(8206)+String.fromCharCode(a.which+1728)),!1;if(95<a.which&&106>a.which)return $(this).val(b+String.fromCharCode(8206)+
String.fromCharCode(a.which+1680)),!1;if(1631<a.which&&1642>a.which)return $(this).val(b+String.fromCharCode(8206)+String.fromCharCode(a.which+144)),!1}})}};$.fn.extend({ApplyPersianDocumentNumberInputFix:function(){return this.each(function(){$(this).is("input[type=text]")&&PersianDocumentNumberInputFix.Apply($(this))})}});