I have a few dynamically builded forms and belonging ID's. The ID's look like id='send_1'... id="send_2"...
Gernerally it will be posted only one form but I don't know how many forms will be created so that I need one general jQuery-function that does the work. At the moment the code below works just for one ID. So I thought it must be possible to loop within a selector with something like while
or foreach
if something like that exists?
$(document).on("submit", "#paypal", function(e){
e.preventDefault();
if ( /\,/.test( $('#send_1').val() ) ) {
$('#send_1').val($('#send_1').val().replace(/,/g, '.'));
} else {
alert('no comma');
}
return false;
});
So how can I do this foreach #send_X
when I do not know how many forms will exist and even don't want to write hundred times the same code just changing the _x
?
If there is someone who could help I really would appreciate.