Page 1 of 11
Forum moderator: bigblog 
uCoz Community » For Webmasters » Custom Solutions » Manipulate strings in blank field of Editing Entry Page
Manipulate strings in blank field of Editing Entry Page
khen
Posts: 434
Reputation: 13
Message # 1 | 3:53 AM
How to manipulate strings in the blank field of Editing Entry Page of my Ad Board.

I have a blank field in the Editing Entry Page of Ad Board. This blank field is intended for the price of the Ad item. I want to manipulate the characters to be entered in the blank field.

As the user types the characters, the user is force to enter numeric characters. Non-numeric characters will be removed on the fly.

This is the field form to be manipulated:

Code
<input type="text" id="bdF13" size="35" class="manFlOth1" style="width:100%;" name="other1" value="Php 3,600,000" maxlength="100">


Please help...

Post edited by khen - Thursday, 2016-09-01, 3:57 AM
bigblog
Great & Powerful
Posts: 1298
Reputation: 62
Message # 2 | 7:25 AM
khen, insert the following code after the $BODY$ tag in the Entry adding/editing page:
Code
<script type="text/javascript">
$("#bdF13").keyup(function () {
    var newValue = $(this).val().replace(/[^0-9]/g,'');
    $(this).val(newValue);    
});  
</script>

trixie took over this account halp
khen
Posts: 434
Reputation: 13
Message # 3 | 1:55 PM
thanks bigblog. You're truly a great helper. You're such a blessing. But there's another thing I want to add. How can I limit the number of characters (numbers) into 10 digits?
bigblog
Great & Powerful
Posts: 1298
Reputation: 62
Message # 4 | 4:45 PM
khen, use the following code which you need to paste before the </script> tag closing of the code from my previous message:
Code
$(document).ready(function() {
  $("bdF13").attr('maxlength',10);
});

Here's a working fiddle: https://jsfiddle.net/osrobcgp/

Tip: You might wanna use
placeholder="Php 3,600,000"
instead of
value="Php 3,600,000"
because it would work and look better. smile

trixie took over this account halp
uCoz Community » For Webmasters » Custom Solutions » Manipulate strings in blank field of Editing Entry Page
Page 1 of 11
Search: