fix(eslint): fix no-useless-escape error (#6734)
[openemr.git] / library / js / erx_javascript.js
blob22411dad435f237d622927fa668522a8bbee4f5a
1 // +-----------------------------------------------------------------------------+
2 // Copyright (C) 2011 ZMG LLC <sam@zhservices.com>
3 //
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 // GNU General Public License for more details.
17 // A copy of the GNU General Public License is included along with this program:
18 // openemr/interface/login/GnuGPL.html
19 // For more information write to the Free Software
20 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22 // Author:   Eldho Chacko <eldho@zhservices.com>
23 //           Vinish K <vinish@zhservices.com>
25 // +------------------------------------------------------------------------------+
26     function checkLength(eleName, eleVal, len) {
27         eleName = eleName.replace('form_', '');
28         var m = '';
29         if (eleVal.length > len)
30             m += window.top.xl("Invalid length for") + ' ' + eleName.toUpperCase() + '. '
31                 + window.top.xl("The length should not exceed the following number of characters") + " : " + len + "\n";
32         return m;
33     }
35     function checkSpecialCharacter(eleName, eleVal) {
36         var regE = /[^a-zA-Z'\s,.-]/;
37         var m = '';
38         eleName = eleName.replace('form_', '');
39         if (regE.test(eleVal) == true)
40             m += window.top.xl("Invalid character in") + ' ' + eleName.toUpperCase() + "\n";
41         return m;
42     }
44     function checkFacilityName(eleName, eleVal) {
45         var regE = /[^a-zA-Z0-9 '().,#:/\-@_%]/;
46         var m = '';
47         eleName = eleName.replace('form_', '');
48         if (regE.test(eleVal) == true)
49             m += window.top.xl("Invalid character in") + ' ' + eleName.toUpperCase() + "\n";
50         return m;
51     }
53     function checkPhone(eleName, eleVal) {
54         var regE = /[^0-9']/;
55         var m = '';
56         eleVal_temp = eleVal.replace(/[^0-9]/ig, '');
57         eleVal = eleVal.replace(/[-)(\s]/ig, '');
58         eleName = eleName.replace('form_', '');
59         eleName = eleName.replace('_', ' ');
60         if (regE.test(eleVal) == true)
61             m += window.top.xl("Invalid non-numeric character in") + ' ' + eleName.toUpperCase() + "\n";
62         else if (eleVal_temp.length > 10)
63             m += eleName.toUpperCase() + ' ' + window.top.xl("should contain only 10 digits") + "\n";
64         else if (eleVal_temp.length < 10)
65             m += eleName.toUpperCase() + ' ' + window.top.xl("should contain 10 digits") + "\n";
66         return m;
67     }
69     function checkTaxNpiDea(eleName, eleVal) {
70         var regE = /[^0-9]/;
71         var m = '';
72         eleName = eleName.replace('_', ' ');
73         if (regE.test(eleVal) == true)
74             m += window.top.xl("Invalid character in") + " " + eleName.toUpperCase() + "\n";
75         return m;
76     }
78     function checkFederalEin(eleName, eleVal) {
79         var regE = /[^a-zA-Z0-9 '().,#:/\-@_%]/;
80         var m = '';
81         eleName = eleName.replace('_', ' ');
82         if (regE.test(eleVal) == true)
83             m += window.top.xl("Invalid character in") + " " + eleName.toUpperCase() + "\n";
84         return m;
85     }
87     function checkStateLicenseNumber(eleName, eleVal) {
88         var regE = /[^a-zA-Z0-9 '.,()#:/\-@_%\r\n]/;
89         var m = '';
90         eleName = eleName.replace('_', ' ');
91         if (regE.test(eleVal) == true)
92             m += window.top.xl("Invalid character in") + " " + eleName.toUpperCase() + "\n";
93         return m;
94     }
96     function checkUsername(eleName, eleVal) {
97         var regE = /[^a-zA-Z0-9 '().,#:/\-@_%]/;
98         var m = '';
99         eleName = eleName.replace('form_', '');
100         if (regE.test(eleVal) == true)
101             m += window.top.xl("Invalid character in") + " " + eleName.toUpperCase() + "\n";
102         return m;
103     }
105     function checkAlphaNumeric(eleName, eleVal) {
106         var regE = /[^a-zA-Z0-9\s]/;
107         var m = '';
108         eleName = eleName.replace('form_', '');
109         eleName = eleName.replace('_', ' ');
110         if (regE.test(eleVal) == true)
111             m += window.top.xl("Invalid character in") + " " + eleName.toUpperCase() + "\n";
112         return m;
113     }
115     function checkAlphaNumericExtended(eleName, eleVal) {
116         var regE = /[^a-zA-Z0-9 '().,#:/\-@_%]/;
117         var m = '';
118         eleName = eleName.replace('form_', '');
119         eleName = eleName.replace('_', ' ');
120         if (regE.test(eleVal) == true)
121             m += window.top.xl("Invalid character in") + " " + eleName.toUpperCase() + "\n";
122         return m;
123     }