|
1
|
|
|
/** |
|
2
|
|
|
* |
|
3
|
|
|
* NOTICE OF LICENSE |
|
4
|
|
|
* |
|
5
|
|
|
* This source file is subject to the GNU General Public License (GPL 3) |
|
6
|
|
|
* that is bundled with this package in the file LICENSE.txt |
|
7
|
|
|
* |
|
8
|
|
|
* DISCLAIMER |
|
9
|
|
|
* |
|
10
|
|
|
* Do not edit or add to this file if you wish to upgrade Payone_Core to newer |
|
11
|
|
|
* versions in the future. If you wish to customize Payone_Core for your |
|
12
|
|
|
* needs please refer to http://www.payone.de for more information. |
|
13
|
|
|
* |
|
14
|
|
|
* @category Payone |
|
15
|
|
|
* @package js |
|
16
|
|
|
* @subpackage payone |
|
17
|
|
|
* @copyright Copyright (c) 2012 <[email protected]> - www.noovias.com |
|
18
|
|
|
* @author Matthias Walter <[email protected]> |
|
19
|
|
|
* @license <http://www.gnu.org/licenses/> GNU General Public License (GPL 3) |
|
20
|
|
|
* @link http://www.noovias.com |
|
21
|
|
|
*/ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* |
|
25
|
|
|
* @param input |
|
26
|
|
|
*/ |
|
27
|
|
|
function inputToUpperCase(input) |
|
28
|
|
|
{ |
|
29
|
|
|
var caretPosition = getCaretPos(input); |
|
30
|
|
|
input.value = input.value.toUpperCase().replace(/\s/g, ''); |
|
31
|
|
|
setCaretPos(input, caretPosition); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* |
|
36
|
|
|
* @param input |
|
37
|
|
|
*/ |
|
38
|
|
|
function inputToUppaerCaseAndNumbers(input) |
|
39
|
|
|
{ |
|
40
|
|
|
var caretPosition = getCaretPos(input); |
|
41
|
|
|
input.value = input.value.toUpperCase().replace(/\W|[_]/g, ''); |
|
42
|
|
|
setCaretPos(input, caretPosition); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* |
|
47
|
|
|
* @param input |
|
48
|
|
|
*/ |
|
49
|
|
|
function inputToNumbers(input) |
|
50
|
|
|
{ |
|
51
|
|
|
var caretPosition = getCaretPos(input); |
|
52
|
|
|
input.value = input.value.replace(/\D/g, ''); |
|
53
|
|
|
setCaretPos(input, caretPosition); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* |
|
58
|
|
|
* @param oField |
|
59
|
|
|
* @returns {number} |
|
60
|
|
|
*/ |
|
61
|
|
|
function getCaretPos(oField) |
|
62
|
|
|
{ |
|
63
|
|
|
var iCaretPos = 0; |
|
64
|
|
|
if (Prototype.Browser.IE) { |
|
|
|
|
|
|
65
|
|
|
var oSel = document.selection.createRange(); |
|
66
|
|
|
oSel.moveStart('character', -oField.value.length); |
|
67
|
|
|
iCaretPos = oSel.text.length; |
|
68
|
|
|
} else { |
|
69
|
|
|
iCaretPos = oField.selectionEnd; |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
return iCaretPos; |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* |
|
77
|
|
|
* @param oField |
|
78
|
|
|
* @param iCaretPos |
|
79
|
|
|
*/ |
|
80
|
|
|
function setCaretPos(oField, iCaretPos) |
|
81
|
|
|
{ |
|
82
|
|
|
if (Prototype.Browser.IE) { |
|
|
|
|
|
|
83
|
|
|
var oSel = document.selection.createRange(); |
|
84
|
|
|
oSel.moveStart('character', -oField.value.length); |
|
85
|
|
|
oSel.moveStart('character', iCaretPos); |
|
86
|
|
|
oSel.moveEnd('character', 0); |
|
87
|
|
|
oSel.select(); |
|
88
|
|
|
} else { |
|
89
|
|
|
oField.selectionStart = iCaretPos; |
|
90
|
|
|
oField.selectionEnd = iCaretPos; |
|
91
|
|
|
oField.focus(); |
|
92
|
|
|
} |
|
93
|
|
|
} |
This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.
To learn more about declaring variables in Javascript, see the MDN.