Things like Validation are typically better to do on the client side - either using pure JavaScript or by making an AJAX call to validate/correct input.
The problem with what you're doing is that you're posting back to the server, so the entire form is essentially sent to the server and then re-rendered. When you come back the focus reverts back to its default control.
The better approach is the capture the change event of the text control and perform your actions there. There's no Proper() function in JavaScript. Something like this:
<divclass="containercontent"> <ww:wwWebTextBoxrunat="server"id="txtName" /><ww:wwWebButtonrunat="server"ID="btnSave"Text="Save" /></div><%= this.Page.JqueryConfig.IncludejQuery("CDN",.T.) %><scripttype="text/javascript"> $().ready(function () { $("#txtName").change(function () { var $name = $(this) var text = $name.val(); $name.val(toTitleCase(text)); }); }); function toTitleCase(str) { return str.replace(/\w\S*/g, function (txt) { return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase(); }); } </script>
If you want to call back with an AJAX callback (ie. validate against hte server) you can use the wwAjaxCallback control to make that easily happen. Define a method on the Page and then use the control to call a method.
Here's the FoxPro method in the Page:
FUNCTION ToProperCase(lcText)RETURNPROPER(lcText)ENDFUNC
Then in the HTML page replace the code that includes jQuery with an wwAjaxMethodCallback control and change the script code:
<ww:wwAjaxMethodCallbackrunat="server"id="Proxy" /><scripttype="text/javascript"> $().ready(function () { $("#txtName").change(function () { var $name = $(this) var text = $name.val(); // local JavaScript call //$name.val(toTitleCase(text)); // Server call Proxy.callMethod("ToProperCase",[text],function (result) { $name.val(result); }); }); });</script>
It's super simple to make AJAX callbacks in Web Control pages.
+++ Rick ---