Fork me on GitHub
js验证Dmeo

JScode:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
<script language="javascript" type="text/javascript">
        <!--
        function changeFormSelect(frmobj, fieldType, fieldValue) {
            //alert(fieldValue);
            for (i = 0; i < frmobj.elements[fieldType].options.length; i++)
                if (frmobj.elements[fieldType].options[i].text == fieldValue) {
                frmobj.elements[fieldType].options[i].selected = true;
                break;
            }
 
        }
        //验证上传的图片
        function CheckExtension(obj) {
            var file = obj.value.toLowerCase();
            var len = file.lastIndexOf(".");
            if (len != -1) {
                var fileExtension = file.substr(len + 1);
                if (fileExtension != "jpg" && fileExtension != "jpeg" && fileExtension != "gif"
            && fileExtension != "bmp" && fileExtension != "icon" && fileExtension != "png") {
                    obj.select(); document.execCommand('Delete');
                    alert("不允许上传该类型文件,请重新上传!");
                    return false;
                }
                else {
                    document.getElementById("imgReview").src = "file:///" + file;
                    // alert(file);
                }
            }
        }
 
        //验证页面数据
        function CheckForm() {
 
            if (Form1.dlbh.options[Form1.dlbh.selectedIndex].value == "" || Form1.zlbh.options[Form1.zlbh.selectedIndex].value == "") {
                alert("请选择药品类别!");
                return false;
            }
 
            if (document.all("filePic").value == "" && document.all("imgReview").src == "../images/casepic.gif") {
                alert("请上传图片");
                return false;
            }
 
            if (document.all("TxtSpName").value == "") {
                alert("请输入商品名!");
                document.all("TxtSpName").focus();
                return false;
            }
            if (document.all("txtEName").value != "") {
                if (CheckEnglish(document.all("txtEName").value) == false) {
                    alert("请输入正确的英文名!");
                    document.all("txtEName").focus();
                    return false;
                }
            }
 
 
            if (document.all("TxtFunction").value == "") {
                alert("请输入产品功能!");
                document.all("TxtFunction").focus();
                return false;
            }
            if (document.all("TxtMainCF").value == "") {
                alert("请输入药品成份!");
                document.all("TxtMainCF").focus();
                return false;
            }
            if (document.all("TxtSYZ").value == "") {
                alert("请输入适应症!");
                document.all("TxtSYZ").focus();
                return false;
            }
            if (document.all("TxtYxq").value == "") {
                alert("请输入药品有效期!");
                document.all("TxtYxq").focus();
                return false;
            }
            if (document.all("TxtDesp").value == "") {
                alert("请输入详细信息!");
                document.all("TxtDesp").focus();
                return false;
 
            }
 
            if (document.all("TxtContacter").value == "") {
                alert("请输入联系人!");
                document.all("TxtContacter").focus();
                return false;
            }
 
            if (document.all("txtYPMZ").value == "") {
                alert("请输入药品名称!");
                document.all("txtYPMZ").focus();
                return false;
            }
 
            if (document.all("TxtProdName").value == "") {
                alert("请输入产地名称!");
                document.all("TxtProdName").focus();
                return false;
            }
 
            if (document.all("txtGG").value == "") {
                alert("请输入药品规格!");
                document.all("txtGG").focus();
                return false;
            }
 
            if (document.all("TxtSpName").value == "") {
                alert("请输入商品名称!");
                document.all("TxtSpName").focus();
                return false;
            }
 
            //            if (document.all("TxtEName").value == "") {
            //                alert("请输入英文名称!");
            //                document.all("TxtEName").focus();
            //                return false;
            //            }
 
            //            if (document.all("txtNono").value == "") {
            //                alert("请输入药品禁忌!");
            //                document.all("txtNono").focus();
            //                return false;
            //            }
 
            if (document.all("TxtYxq").value == "") {
                alert("请输入药品有效期!");
                document.all("TxtYxq").focus();
                return false;
            }
 
            if (document.all("TxtFunction").value == "") {
                alert("请输入产品功能!");
                document.all("TxtFunction").focus();
                return false;
            }
 
            if (document.all("TxtMainCF").value == "") {
                alert("请输入药品的主要成分!");
                document.all("TxtMainCF").focus();
                return false;
            }
            //            if (document.all("TxtXZ").value == "") {
            //                alert("请输入药品性状!");
            //                document.all("TxtXZ").focus();
            //                return false;
            //            }
 
            if (document.all("TxtSYZ").value == "") {
                alert("请输入药品的适应症!");
                document.all("TxtSYZ").focus();
                return false;
            }
 
            //            if (document.all("TxtG").value == "") {
            //                alert.all("请输入药品的作用类别!");
            //                document.all("TxtG").focus();
            //                return false;
            //            }
 
            //            if (document.all("TxtChuCang").value == "") {
            //                alert.all("请输入药品贮藏!");
            //                document.all("TxtChuCang").foucs();
            //                return false;
            //            }
 
            //            if (document.all("TxtMadeFact").value == "") {
            //                alert("请输入药理作用!");
            //                document.all("TxtMadeFact").focus();
            //                return false;
            //            }
            //            if (document.all("txtUserMethod").value == "") {
            //                alert("请输入用法用量!");
            //                document.all("txtUserMethod").focus();
            //                return false;
            //            }
            //            if (document.all("TxtSupport").value == "") {
            //                alert("请输入注意事项!");
            //                document.all("TxtSupport").focus();
            //                return false;
            //            }
            //            if (document.all("TxtRequire").value == "") {
            //                alert("请输入药物相互作用!");
            //                document.all("TxtRequire").focus();
            //                return false;
            //            }
            //            if (document.all("TxtMemo").value == "") {
            //                alert("请输入不良反映!");
            //                document.all("TxtMemo").focus();
            //                return false;
            //            }
 
 
            if (document.all("TxtPhone").value == "") {
                alert("请输入电话!");
                document.all("TxtPhone").focus();
                return false;
            }
            else {
                if (document.all("TxtPhone").value != "") {
                    //if(CheckPhone(document.all("TxtPhone").value) == false)
                    if (MyCheckPhone(document.all("TxtPhone").value) == false) {
                        alert("电话输入有误,请重新输入!");
                        document.all("TxtPhone").focus();
                        return false;
                    }
                }
            }
            if (document.all("TxtFax").value != "") {
                //if(CheckPhone(document.all("TxtFax").value) == false)
                if (MyCheckPhone(document.all("TxtFax").value) == false) {
                    alert("传真输入有误,请重新输入!");
                    document.all("TxtFax").focus();
                    return false;
                }
            }
            if (document.all("TxtMobile").value == "") {
                alert("请输入手机号!");
                document.all("TxtMobile").focus();
                return false;
            }
            else {
                if (document.all("TxtMobile").value != "") {
                    if (CheckMobile2(document.all("TxtMobile").value) == false) {
                        alert("手机输入有误,请重新输入!");
                        document.all("TxtMobile").focus();
                        return false;
                    }
                }
            }
 
            if (document.all("TxtEmail").value != "") {
                if (CheckEmail(document.all("TxtEmail").value) == false) {
                    alert("Eamil格式不正确!");
                    document.all("TxtEmail").focus();
                    return false;
 
                }
 
            }
 
            if (document.all("TxtUrl").value != "") {
                //if( CheckUrl(document.all("TxtUrl").value) == false )
                if (IsURL(document.all("TxtUrl").value) == false) {
                    alert("请输入正确的url");
                    document.all("TxtUrl").focus();
                    return false;
 
                }
 
            }
 
            return true;
 
        }
        function CheckEnglish(str) {
            var reg = /^[A-Za-z]+$/;
            return Check(reg, str);
        }
 
        //url
        function CheckUrl(str) {
            var reg = /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\- &_~`@[\]\':+!]*([^<>\"\"])*$/;
 
            return Check(reg, str);
        }
 
 
        //Phone,办公电话
        function CheckPhone(str) {
            var reg = /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d {2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/;
            return Check(reg, str);
 
 
        }
 
        //Phone,办公电话 例如:(0511-4405222、021-87888822、021-44055520-555、(0511)4405222 ,(021)44052225 ,4405222 ,44052228 )
        //hyey.wl time:2010-04-29
        function MyCheckPhone(str) {
            var reg = /^((\(\d{3}\)|\d{3}-)?\d{8}|(\(d{4}\)|d{4}-)?\d{7}|(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})|(\d{4}|\d{3})-(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1})|(\d{7,8})-(\d{4}|\d{3}|\d{2}|\d{1}))$/; //   (\(\d{3}\)|\d{3}-)?\d{8}|(\(d{4}\)|d{4}-)?\d{7}
            return Check(reg, str);
 
        }
 
        // Mobile
        function CheckMobile(str) {
            var reg = /^((\(\d{2,3}\))|(\d{3}\-))?13\d{9}$/;
            return Check(reg, str);
 
        }
        //Mobile
        function CheckMobile2(str) {
            if (str.length != 11) {
                return false;
 
            }
            if (isNaN(str)) {
 
                return false;
            }
            return true;
 
        }
 
        // Email
        function CheckEmail(str) {
            var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;
            return Check(reg, str);
        }
        function Check(reg, str) {
            if (reg.test(str)) {
                return true;
            }
            return false;
        
       -->
    </script>
 
    <script language="JavaScript">
        //hyey.wl 2010-04-29
        <!--
        function IsURL(str_url){
        var strRegex = "^((https|http|ftp|rtsp|mms)?://)"
        + "?(([0-9a-z_!~*'().&=+$%-]+: )?[0-9a-z_!~*'().&=+$%-]+@)?" //ftp的user@
                + "(([0-9]{1,3}\.){3}[0-9]{1,3}" // IP形式的URL- 199.194.52.184
                + "|" // 允许IP和DOMAIN(域名)
                + "([0-9a-z_!~*'()-]+\.)*" // 域名- www.
                + "([0-9a-z][0-9a-z-]{0,61})?[0-9a-z]\." // 二级域名
                + "[a-z]{2,6})" // first level domain- .com or .museum
                + "(:[0-9]{1,4})?" // 端口- :80
                + "((/?)|" // a slash isn't required if there is no file name
                + "(/[0-9a-z_!~*'().;?:@&=+$,%#-]+)+/?)$";
                var re=new RegExp(strRegex);
                //re.test()
                if (re.test(str_url)){
                    return (true);
                }else{
                    return (false);
                }
            }
        -->
    </script>
posted on   HackerVirus  阅读(285)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示