Hello there!,
I have text boxes, drop down list boxes in my web page (C#) . i am passing the client id of the controls to one jscriptthat is
txtcode.Attributes.Add("OnChange", "return Validation(\'" + (txtcode.ClientID + "\',\'Code\');"));
txtphone.Attributes.Add("OnChange", "return Validation(\'" + (txtphone.ClientID + "\',\phone number\');"));
txtname.Attributes.Add("OnChange", "return Validation(\'" + (txtname.ClientID + "\',\'Name\');"));
txtCity.Attributes.Add("OnChange", "return Validation(\'" + (txtCity.ClientID + "\',\'City Code\');")); txtState.Attributes.Add("OnChange", "return Validation(\'" + (txtState.ClientID + "\',\'State Code\');"));
so i am here passing the client id of the control and i will catch the those in the jscript like
function Validation(ctrl,type) { var str = document.getElementById(ctrl).value; if (str.length<1||!str.match(/[^\s]/)) {
alert("Please Enter"+" "+type); document.getElementById (ctrl).focus(); document.getElementById (ctrl).value=""; return false; } return true; } i am just validating those controls when only there text changes.
consider when i want to validate those text boxes when the submit button is clicked, then how can i pass all their ids in to one function which executes when the submit button is clicked
that is
like
btnSubmit.Attributes.Add("OnClick", "return whole(\"'some values"')");
Could you please tell me a solution?