WordPress, of course, there are forms of verification, but we all know that the user experience is not good, the page jumps, and sometimes the form will be emptied, and the front desk form certification seems very necessary. The following is my written by changing the text box background color prompts the user input content, WordPress as long as the following code into the JS file can work. The validation is triggered by clicking on the Submit button and working to see the annotation.
The code is as follows |
Copy Code |
Form validation $ (function () { $ (' #submit '). Click (function () { var $author =$ (' #author '). Val (); Name var $email =$ (' #email '). Val (); Mailbox var $url =$ (' #url '). Val (); Url var $textarea =$ (' Textarea:first '). Val (); Comments var $errorNo = 0; if ($author = = "") { $ (' #author '). CSS ("Background", "#F9A4A4"); $errorNo +=1; }else{ $ (' #author '). CSS ("Background", "#FFF"); } if ($email = = "") { $ (' #email '). CSS ("Background", "#F9A4A4"); $errorNo +=1; }else if (!/^: [a-zd]+[_-+.]?) *[a-zd]+@ (?:( [a-zd]+-?] *[a-zd]+.) + ([A-z]{2,}) +$/i.test ($email)) { $ (' #email '). CSS ("Background", "#F9A4A4"); $errorNo +=1; }else{ $ (' #email '). CSS ("Background", "#FFF"); } if ($url!= "" &&!/^http://[a-za-z0-9]+.[ a-za-z0-9]+[/=?%-&_~ ' @[] ': +!] * ([^<> ""]) *$/.test ($url)) { $ (' #url '). CSS ("Background", "#F9A4A4"); $errorNo +=1; }else{ $ (' #url '). CSS ("Background", "#FFF"); } if ($textarea = = "") { $ (' Textarea:first '). CSS ("Background", "#F9A4A4"); $errorNo +=1; }else{ $ (' Textarea:first '). CSS ("Background", "#FFF"); } if ($errorNo >0) { return false; } }); }); |
Such a very simple verification of the form came out ~ The effect is Xiao Bo now, welcome to improve ~
Example 2
Determine if the dropdown box has a selection:
The code is as follows |
Copy Code |
<script type= "Text/javascript" > function Checkform () { var areavalue=$ ("#DDlAreaList"). Val (); if (areavalue== "0") { Top. Dialog.altert ("Please select area!") "); return false; } return true; } </scirpt> <asp:button id= "btnsubmit" runat= "Server" text= "Save and Return" Width= "80px" cssclass= "Bluebuttoncss" onclientclick= " return Checkfrom (); " onclick= "btnSubmit_Click"/> |
About the use of SQL statements in Ibatisnet:
The code is as follows |
Copy Code |
<!--<select id= "searchdeclaration" resultmap= "T_ed_declarationresult" parameterclass= "T_ED_Declaration" > SELECT a.* from [t_ed_declaration] A <dynamic prepend= "WHERE" > <isnotempty prepend= "and" property= "Declaration_batchno" > A.declaration_batchno like '% $Declaration _batchno$% ' </isNotEmpty> <isnotequal prepend= "and" property= "Declaration_portname" comparevalue= "0" > A.declaration_portname like '% $Declaration _portname$% ' </isNotEqual> <isgreaterthan prepend= "and" property= "StartTime" comparevalue= "1900-1-1" > <! [cdata[ a.starttime<= #StartTime # ]]> </isGreaterThan> <isgreaterthan prepend= "and" property= "Endtime" comparevalue= "1900-1-1" > <! [cdata[ a.endtime<= #EndTime # ]]> </isGreaterThan> </dynamic> </select>--> |