Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

223
Views
How can i remove zero from input number in form javascript?

I have this code and I want to remove first zero from phone number.

mobile = $('#country_code').val();
        mobile += input.val();

Country code is: 966

Phone input is: 055642444

And output in this code is: 966055642444

I want it to be 96655642444 without zero after country code.

Thanks

about 4 years ago · Juan Pablo Isaza
3 answers
Answer question

0

Have you tried parseInt(), integers don't have leading 0s - https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/parseInt

mobile = $('#country_code').val();
        mobile += parseInt(input.val());
about 4 years ago · Juan Pablo Isaza Report

0

You can use substring to remove the first N characters from a string.

First of all, assign a variable with the value of input.val()

let str = input.val()

Now, you can index the Nth element of str and check its value:

if (str[0] === "0") str = str.substring(1)

With this, you have successfully checked if the first character is "0" and reassigned the str variable accordingly.

about 4 years ago · Juan Pablo Isaza Report

0

For this, I'd use substring which returns a new string. Example :

mobile = '0652447766';
mobile = mobile.substring(1)
console.log('mobile = ', mobile)

>> mobile = '652447766'

Warning ! Calling mobile.substring() doesn't actually modify mobile ! Strings are immutable in Js, so you'll have to get the returned value of substring() with mobile = mobile.substring(1)

Hope it helped !

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!