Client enters addresses in a standard format across most systems so in keeping with that format we have a field on an early form that collects address in this format – Street Name Street Number (Main Street 2134). In a later form we need to do a lookup based on address but need Street Number Street Address as the query submission. So, as still a beginner to JavaScript I need help with doing pattern matching then flipping street number and address and passing it to a new field on the same form to do the lookup. Below is the Javascript that I have attempted with no luck so far and obviously may be going the wrong direction on this. Original is the class assigned to the address field that contains the data as Street Address Street Number. Lookup is the class assigned to the field that needs to be Street Number Street Address and will be submitted as the lookup data. Thanks for the help.
$(document).ready(function () { var site = ('.original input'); var newadd = site.replace(/(\D*)(\d*)/, "$2, $1"); $('.lookup input').val(newadd); });
mod edit: placed javascript code in a code-block for readability