The project encountered a change in customer needs, to verify the correctness of a certain data, determine the input two characters, the first digit is the number 16 binary, the second is I, O, Q, u except the letter (A to Z).
Originally to JS is not proficient, on-line reference to JS regular validation rules, using regular expressions to complete this verification.
1 functionCheck () {2 varstr = document.getElementById ("Txtenglishname"). Value;3 varreg=/^[0-9a-fa-f][^ioqu]$/;4 if(str.length!=2) {5Mybox ({title: ' Hint ', content: ' Please enter the two-character English name! The first subsystem code is the number 16 binary, the second component is the letter I, O, Q, and U except the letters (A to Z) ', width:300, height:200, Pos: ' Center ' });6 return false;7 }8 Else {9 if(!reg.test (str)) {TenMybox ({title: ' Hint ', content: ' Please enter the two-character English name! The first subsystem code is the number 16 binary, the second component is the letter I, O, Q, and U except the letters (A to Z) ', width:300, height:200, Pos: ' Center ' }); One return false; A } - } -}
Use JS to judge the input two characters, the first digit is the number 16 binary, the second is I, O, Q, u except the letter (A to Z)