PageSourceSearch

https://skyworthxr.com/views/contact/js/index.js

js skyworthxr.com collected 2026-10-07 06:55:29 UTC 2,423 bytes, 95 lines download raw bytes

1// 检验是否输入为空
2function isRequired(inputEl) {
3  const text = $(inputEl).val().replace(/\n|\r|\s+/gm, '')
4  const errorIdStr = $(inputEl).attr('error')
5  if (text) {
6    $(`#${errorIdStr}`).hide()
7    return true
8  } else {
9    $(`#${errorIdStr}`).show()
10    return false
11  }
12}
13/*
14 * 验证手机号是否合格
15 * true--说明合格
16 */
17// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
18 function isPhone(phone) {
19  const phoneStr = $(phone).val()
20  const myreg = /^[1][3,4,5,7,8,9][0-9]{9}$/
21  if (!myreg.test(phoneStr)) {
22    $('#phone-error').show()
23    return false
24  } else {
25    $('#phone-error').hide()
26    return true
27  }
28}
29
30// 检验邮箱是否正确
31function validEmail(email) {
32  const emailStr = $(email).val()
33  const myreg = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
34  if (!myreg.test(emailStr)) {
35    $('#email-error').show()
36    return false
37  } else {
38    $('#email-error').hide()
39    return true
40  }
41}
42
43// 遍历form表单输入框添加blur事件
44$('.form-control').each(function () {
45  const inputEl = this
46  $(inputEl).blur(function () {
47    isRequired(inputEl)
48  })
49})
50
51// 邮箱输入框添加验证
52$('#form-email').blur(function () {
53  validEmail(this)
54})
55// 手机号输入框添加验证
56$('#form-phone').blur(function () {
57  isPhone(this)
58})
59
60// 点击提交
61let submitStatus=false;
62$('#submit-btn').click(function () {
63  if(submitStatus) return false;
64  const errList = []
65  $('.form-control').each(function () {
66    const isNull = isRequired(this)
67    errList.push(isNull)
68  })
69  const isPhones = isPhone($('#form-phone'))
70  if (errList.includes(false) || !isPhones) {
71    return false
72  }
73  submitStatus=true
74  const name = $('#form-name').val()
75  const phone = $('#form-phone').val()
76  const firm = $('#form-subject').val()
77  const area = $('#form-province').val()
78  const msg = $('#form-message').val()
79  const params = {
80    name, phone,area, firm, msg
81  }
82  axios.post('https://api.skyworthxr.com/cms/api/public/contactUs/domestic', params).then((res) => {
83    if (res.data.code === 0) {
84      $('.form-control').each(function () {
85        $(this).val('')
86      })
87      $('#submit-btn').prop('disabled', true)
88      $("#submit-btn").html('已发送')
89    } else {
90      message.error(res.data.msg)
91    }
92  }).catch((err) => {
93
94  });
95})

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.