System. Web. UI. htmlcontrols;
Namespace Demo
{
Public Partial Class Webform1: system. Web. UI. Page
{
Koodoo. validation. formvalidate FV;
Protected Void Page_load ( Object Sender, eventargs E)
{
FV = New Koodoo. validation. formvalidate ( This , " Button1 " , True );
FV. valiajaxemail ( " Useremail " , " Enter an email in the correct format. " , " The email you entered already exists. " , " Checkemail. aspx " , " Key " );
FV. valinormalnumber ( " Textbox1 " , " Enter a number ranging from 2 to 6. " , False , 2 , 6 );
FV. valicompare ( " Textbox2 " , " The previous number is not equal. " , " Textbox1 " );
FV. valicheckbox ( " Checkboxlist1 " , " Select at least two " , 2 );
FV. valiradio ( " Radiobuttonlist1 " , " Select " );
FV. valiselect ( " Dropdownlist1 " , " Select " , " Select " );
FV. Display ();
}
Protected Void Button#click ( Object Sender, eventargs E)
{
If (FV. submit_server ())
{
Response. Write ( " Verification passed " );
}
Else
{
Response. Write ( " Verification Failed " );
}
}
}
}
Instantiation 1-> parameter 1: Current page, parameter 2: Submitted button, parameter 3: whether it is in development stage (when it is in development stage, every time JavaScript code is generated, it is placed under the JS folder of the website. If it is in the running stage, it is set to false)
FV = new koodoo. validation. formvalidate (this, "button1", true );
Instantiation 2-> parameter 1: Current page, parameter 2: submit button, parameter 3: Display error message mode (1: Each control has a correct label Display error, 2: Display All error messages on a specified label, 3: display an error message on a specified label) parameter 4: display the specified label of the error message, valid when parameter 3 is 2 and 3. Parameter 5: whether it is in development stage
FV = new koodoo. validation. formvalidate (this, "buttin1", 1, "errmsg", true );
After use, call display () to add JS Code to the page.
Submit_server () is called for server-side verification. If true is returned, the verification succeeds.
When an error is reported through verification, you can customize the JS script to display some custom error reports on the page.
As I used here: (Note: when the error reporting method is 1, the ID of the label that shows the error is, and the verified control is added with "_ Err ", if "_ x" is added when "required" is added, it is not clear. Check the source code)
VaR showerr = function (ID)
{
$ ("#" + Id). ATTR ("style", "border: 1px # ff0000 solid ;");
$ ("#" + ID + "_ Err"). ATTR ("style", "color: Red ");
$ ("#" + ID + "_ x"). ATTR ("style", "color: Red ");
}
VaR hideerr = function (ID ){
$ ("#" + Id). ATTR ("style ","");
$ ("#" + ID + "_ Err"). ATTR ("style ","");
$ ("#" + ID + "_ x"). ATTR ("style ","");
}
For more information, see the source code.
Source code updatedSource code download
I sent it to the homepage for the first time, waiting for you to make a picture.