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.