A thread earlier today asked about this. I decided to start a new thread to answer with a title that's more appropriate so that the Search function may better find it.

I didn't invent this Javascript - I found it someplace and should provide attribution, but I didn't record my source, so I apologize for that omission. But it is pretty standard construct. Anyway:

Put this function in the page header:

Code:
<script LANGUAGE="JavaScript">
function format_Sphone() {
var p
p=document.getElementById('Grid_Customers_S_PHONE').value
if (p.length==3){
	p=p+'-';
	document.getElementById('Grid_Customers_S_PHONE').value=p
}
if (p.length==7){
	p=p+'-';
	document.getElementById('Grid_Customers_S_PHONE').value=p
}
if (p.length==12){
	document.Grid_Customers_Search.submit();
}
}
</script>
A couple things worth noting here:

  1. This function is hard-coded to a control with an ID of 'Grid_Customers_S_PHONE'. I think that's obvious, but your control may well have a different ID.
  2. This particular control is in the Search part of a grid. You'll see that when the length = 12, the function Submits the search.


Next, you need to know how to implement this function in the grid. Here's my code to use as an example:

Code:
SearchStr = <<%a%
name="Grid_Customers_S_PHONE"%a%
ReplaceStr = <<%a%
name="Grid_Customers_S_PHONE" onkeyup="format_Sphone()"%a%
x_Grid_Customers.Output.Body.Search_HTML = stritran(x_Grid_Customers.Output.Body.Search_HTML, SearchStr, ReplaceStr)
More notes:

  1. For those unfamiliar with this method, you insert this between %A5 tags on the A5W page that calls the grid.
  2. The code must be installed after the x_Grid_Customers.... has been created (Alpha's genie does this for you when you insert the component).