<Scriptsrc= "Jquery-1.7.2.min.js"type= "Text/javascript"></Script> <Scripttype= "Text/jscript"> functionNotnull () {varCount= 0; $("Input[type=text]"). each (function () { if ($( This). Val ()== "') {alert ('please fill in the complete information! '); Count++; return false; } }); if(Count> 0) { return false; } } </Script>
<Body> <formID= "Form1"runat= "Server"> <Div> <inputID= "Text1"type= "text" /><BR/> <inputID= "Text2"type= "text" /><BR/> <inputID= "Text3"type= "text" /><BR/> <inputtype= "Submit"ID= "Handon"value= "Submit User"runat= "Server"onclick= "return Notnull ()"OnServerClick= "Addnew" /> <Asp:buttonID= "Button1"runat= "Server"Text= "button"onclick= "Addnew" /> </Div> </form></Body>
Background Code AddNew event:
protected void Addnew (object sender, EventArgs e) { Response.Write ("<script >alert (' User name and password cannot be empty! ') </script>"); }
Fill in some information:
Fill in all information:
20150528-html using jquery to traverse the non-null validation of the text box