Reputation: 13080
I have 3 input in form
<input type="text" name="full" />
<input type="text" name="FilterLeft" />
<input type="text" name="FilterRight" />
When user typing in $(#full), function must be devide value into left side after last non-numeric symbol, and right side after last non-numeric symbol.
For example, if user typed '6s3f23234'
.
I want to divide it into $('#FilterLeft').val('6s3f')
and $('#FilterRight').val('23234')
. How to do this? thanks.
Upvotes: 1
Views: 146
Reputation: 141917
var str = $('#full').val();
var matches = str.match(/(.*?)([\d]*$)/);
$('#Filterleft').val(matches[1] || '');
$('#FilterRight').val(matches[2] || '');
PS: You should pick one way to name your ids and stick to it. Either left should be capitalized in Filterleft, or Right should be made lowercase.
Upvotes: 3