A page, there is a text box and a submission button, and there is a validation control to verify the input in the text box, and simultaneously trigger a JavaScript script while clicking Button.
Add: Button1.attribute.Add ("onclick", "Return Check Port ()");
The runtime prompts have a script error, lack of ";"
The generated HTML: can find: Checkagree () is indeed lacking ";"
Change to: Button1.attribute.Add ("onclick", "Return Check Port ();");
The script error is not prompted at runtime, but the verification control does not work.
The generated HTML: can find: OnClick calls the checkagree () function is returned directly, and the verification script is not called.
Change to: Button1.attribute.Add ("Onclick", "IF (page_clientValidate ()) return checkagree ();");
Do not prompt script errors when running, and verify controls, but the page verifies twice
The generated HTML: can find that the page is verified before calling the checkgree () function, but if the page does not verify, the following IF (TypeOf (Page_ClientValidate) == 'function') Page_clientValidate (); once a verification is performed.
Change to: Button1.attribute.Add ("OnClick", "IF ()) {eturn checkagree ();} else {return false;}"); problem solving
Generated HTML: But you can see if (typeof (page_clientvalidate == 'function') Page_clientValidate (); is a spam code, it will not carried out
Set the CausesValidation of Button1 to false, generated HTML: can be seen, no spam code.
But I want to execute checkagree (), if you return to True to verify the page, you can write:
Button1.attribute.Add ("OnClick", "Return Checkagree ()");
Function checkagree () {if (! Document.all ["checkbox"]. Checked) {alert ("If you continue to register, you must agree to agree!"); return false;} else {if (Page_clientValidate ()) {Return True } Else {returnaf false;}}}