Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
85
rated 0 times [  86] [ 1]  / answers: 1 / hits: 168260  / 12 Years ago, tue, may 1, 2012, 12:00:00

I am creating a form to lookup the details of a support request in our call logging system.


Call references are assigned a number like F0123456 which is what the user would enter, but the record in the database would be 123456. I have the following code for collecting the data from the form before submitting it with jQuery ajax.


How would I strip out the leading F0 from the string if it exists?


$('#submit').click(function () {        

var rnum = $('input[name=rnum]');
var uname = $('input[name=uname]');

var url = 'rnum=' + rnum.val() + '&uname=' + uname.val();

More From » string

 Answers
189

Simply replace it with nothing:



var string = 'F0123456'; // just an example
string.replace(/^F0+/i, ''); '123456'

[#85872] Sunday, April 29, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jaliyahcynthiac

Total Points: 91
Total Questions: 94
Total Answers: 119

Location: Vanuatu
Member since Wed, Oct 14, 2020
4 Years ago
;