General

ASP.net Client-side Validation

A couple of days ago, I faced a situation whereby I needed to add some form validation to an aspx page. I had options of either JavaScript or ASP.net client side validation. JavaScript seemed like an easier solution... <h5>Client-side JavaScript for form validation</h5> [code lang="js"] <script language="javascript"> <!-- Function CheckForm(form) { for(var intCtr = 0; intCtr <= (form.elements.length - 5); ++intCtr) { var temp = form.elements[intCtr]; if(temp.type == "text" && temp.value == "") { alert("Please Enter All Information!"); temp.focus(); return false; } } return true; } //--> </script> [/code]

(more…)

By Given Mthimunye, ago