My demo: Schedule Verification

Source: Internet
Author: User
// Kssj cannot be earlier than the current system time and can only be between-and function checkkssj () {var kssj = jquery (": Text [name = 'vo. kssj'] "); var kstime = kssj. val (); var year = kstime. split ("-") [0]; var MON = kstime. split ("-") [1]; var month = parseint (Mon)-1 + ""; var date = kstime. split ("-") [2]. split ("") [0]; var H = kstime. split ("-") [2]. split ("") [1]. split (":") [0]; var M = kstime. split ("-") [2]. split ("") [1]. split (":") [1]; var S = ksti Me. split ("-") [2]. split ("") [1]. split (":") [2]; var ksdate = new date (year, month, date, H, M, S); var sysdate = new date (); if (sysdate. gettime ()> ksdate. gettime () {jquery (kssj ). parent (). find ("span "). remove (); jquery ("<span> <br> \ u4e0d \ u80fd \ u5c0f \ u4e8e \ u7cfb \ u7edf \ u65f6 \ u95f4! </Span> ").css (" color "," Red "). appendto (jquery (kssj ). parent (); Return false;} else {If (H <8 | h> 18) {jquery (kssj ). parent (). find ("span "). remove (); jquery ("<span> <br> \ u53ea \ u80fd \ u9009 \ u62e98: 00-18:00 \ u4e4b \ u95f4! </Span> ").css (" color "," Red "). appendto (jquery (kssj ). parent (); Return false;} else {jquery (kssj ). parent (). find ("span "). remove (); Return true ;}}// bssj can only be an integer. Function checkbssj () {var BSSC = jquery (": Text [name = 'vo. bssj'] "); If (! Valiint (BSSC. val () {jquery (BSSC ). parent (). find ("span "). remove (); jquery ("<span> <br> \ u6bd4 \ u8d5b \ u65f6 \ u957f \ u53ea \ u80fd \ u4e3a \ u6570 \ u5b57! </Span> ").css (" color "," Red "). appendto (jquery (BSSC ). parent (); Return false;} else {jquery (BSSC ). parent (). find ("span "). remove (); Return true ;}}// bsje can only be an integer. Function checkbsje () {var bsje = jquery (": Text [name = 'vo. bsje '] "); If (! Valiint (bsje. val () {jquery (bsje ). parent (). find ("span "). remove (); jquery ("<span> <br> \ u6bd4 \ u8d5b \ u95f4 \ u9694 \ u53ea \ u80fd \ u4e3a \ u6570 \ u5b57! </Span> ").css (" color "," Red "). appendto (jquery (bsje ). parent (); Return false;} else {jquery (bsje ). parent (). find ("span "). remove (); Return true ;}}// submit the function isnull () {var kssj = jquery (": Text [name = 'vo. kssj'] "). val (); var BSSC = jquery (": Text [name = 'vo. bssj'] "). val (); var bsje = jquery (": Text [name = 'vo. bsje '] "). val (); var bslx = jquery ("# bspc"); If (trimall (kssj) = "") {alert ("\ u8bf7 \ u9009 \ u62e 9 \ u6bd4 \ u8d5b \ u5f00 \ u59cb \ u65f6 \ u95f4 \ uff01 "); Return false;} If (trimall (BSSC) = "") {alert ("\ u8bf7 \ u8f93 \ u5165 \ u6bd4 \ u8d5b \ u65f6 \ u957f \ uff01"); Return false;} If (trimall (bsje) = "") {alert ("\ u8bf7 \ u8f93 \ u5165 \ u6bd4 \ u8d5b \ u95f4 \ u9694 \ uff01"); Return false;} var kssjflag = checkkssj (); vaR bssjflag = checkbssj (); var bsjeflag = checkbsje (); If (kssjflag = false) {alert ("\ u5f00 \ u59cb \ u65f 6 \ u95f4 \ u9519 \ u8bef \ uff01 "); Return false;} If (bssjflag = false) {alert ("\ u6bd4 \ u8d5b \ u65f6 \ u957f \ u8f93 \ u5165 \ u9519 \ u8bef \ uff01"); Return false;} If (bsjeflag = false) {alert ("\ u65f6 \ u95f4 \ u95f4 \ u9694 \ u8f93 \ u5165 \ u9519 \ u8bef \ uff01"); Return false;} If (bslx = 2) {var hql = "select max (. kssj) from ccap where. ssgl. kqzt = 1 and. bspc = 2 "; var hql2 =" select. bsje from ccap where. ssgl. kqzt = 1 and. bspc = 2 "; userdwr. isrighttime (hql, hql2, kssj. val (), function (data) {If (Data = false) {jquery (kssj ). parent (). find ("span "). remove (); jquery ("<span> <br> it cannot be earlier than the end time of the last semi-finals! </Span> ").css (" color "," Red "). appendto (jquery (kssj ). parent (); Return false;} else {jquery (kssj ). parent (). find ("span "). remove (); Return true ;}}); var numflag1 = checknum1 (); alert ("numflag1" + numflag1); If (numflag1 = false) {alert ("the number of semi-finals is incorrect! "); Return false;} else {return true;} If (bslx = 3) {var hql =" select max (. kssj) from ccap where. ssgl. kqzt = 1 and. bspc = 3 "; var hql2 =" select. bsje from ccap where. ssgl. kqzt = 1 and. bspc = 3 "; userdwr. isrighttime (hql, hql2, kssj. val (), function (data) {If (Data = false) {jquery (kssj ). parent (). find ("span "). remove (); jquery ("<span> <br> it cannot be earlier than the end time of the last semi-finals! </Span> ").css (" color "," Red "). appendto (jquery (kssj ). parent (); Return false;} else {jquery (kssj ). parent (). find ("span "). remove (); Return true ;}}); var numflag2 = checknum2 (); If (numflag2 = false) {alert ("the number of finalists is incorrect! "); Return false;} else {return true ;}// when the competition type is 2 or 3, enter the number of participating teams function checkbslx () {var bslx = jquery ("# bspc"); If (bslx. val () = 1) {jquery (bslx ). parent (). find ("span "). remove ();} else if (bslx. val () = 2) {jquery (bslx ). parent (). find ("span "). remove (); jquery ("<span> input a multiple of 4: <input type = 'text' name = 'num1' width = '2px 'onblur = 'checknum1 () '> </span> "). appendto (jquery (bslx ). parent ();} else if (BSL X. val () = 3) {jquery (bslx ). parent (). find ("span "). remove (); jquery ("<span> input a multiple of 4: <input type = 'text' name = 'num2' width = '2px 'onblur = 'checknum2 () '> </span> "). appendto (jquery (bslx ). parent () ;}} function checknum1 () {var flag; var num = jquery (": Text [name = 'num1']"); If (Num. val () = "") {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> you must enter the number of participating teams! </Span> ").css (" color "," Red "). appendto (jquery (Num). Parent (); Return false;} else if (! Valiint (Num. val () {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> only integers can be entered! </Span> ").css (" color "," Red "). appendto (jquery (Num ). parent (); Return false;} else if (Num. val () % 4! = 0) {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> the number of inputs must be 4! </Span> ").css (" color "," Red "). appendto (jquery (Num ). parent (); Return false;} else {// determines whether the number entered exceeds the total number in the ranking. var hql = "select count (a) from phb a where. CSDW. ssgl. kqzt = 1 and. bslx = 1 "; userdwr. isrightnum (hql, function (data) {If (Data <num. val () {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> the score of the Cross competition has not been completed yet, and no match can be arranged yet! </Span> ").css (" color "," Red "). appendto (jquery (Num ). parent (); flag = false;} else {flag = true ;}});} If (flag = false) {return false;} else {return true ;}} function checknum2 () {var num = jquery (": Text [name = 'num2']"); var flag; If (Num. val () = "") {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> you must enter the number of participating teams! </Span> "). appendto (jquery (Num). Parent (); Return false;} else if (! Valiint (Num. val () {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> only integers can be entered! </Span> "). appendto (jquery (Num). Parent (); Return false;} else if (Num. Val () % 4! = 0) {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> the number of inputs must be 4! </Span> "). appendto (jquery (Num ). parent (); Return false;} else {// determines whether the number entered exceeds the total number in the ranking. var hql = "select count (a) from phb a where. CSDW. ssgl. kqzt = 1 and. bslx = 2 "; userdwr. isrightnum (hql, function (data) {If (Data <num | (data/num. val ())! = 2) {jquery (Num ). parent (). find ("span "). remove (); jquery ("<span> <br> only half of the number of semi-finals (" + Data +! </Span> "). appendto (jquery (Num ). parent (); flag = false;} else {flag = true ;}});} If (flag = false) {return false;} else {return true ;}}

During the schedule, you can find that the formats of the start time, interval, length, type, and implicit parameters that need to be verified can be completed on the page.

For example:

1. the start time cannot be earlier than the system time.

2. the start time can only be between and.

3. The length and interval of the game can only be an integer.

4. For semi-finals or finals, enter the number of participating teams. An input box is displayed.

In this way, unnecessary server access is reduced, and the programs on the server do not have to do anything unrelated to the business.

I have never studied front-end technologies such as JavaScript and Ajax before, so I am not very conscious of this. In the future, you should note that as long as the verification is input at the front end, JavaScript or Ajax should be used for verification as much as possible.

Through this example, we must establish such an idea.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.