Question

I keep loosing my leading 0 from a phone number field on my user sign-up form. I use JQuery to get the value of the fields, then send them to a processing page via Get.

My phone number fields are split into 3 parts. The third input field looks like this:

<input name="phone3" type="tel" id="phone3" class="TextField30" maxlength="4" required>

I also tried having the type as text.

My jQuery for this field looks like this:

$p3=""+$('#phone3').val();

I also tried $p3=""+$('#phone3').attr('value'); since I thought that accessing it via the attribute meant that it would leave it as a string instead of converting it to a number.

Was it helpful?

Solution 2

I figured out the issue actually wasn't in the html or jQuery - it was that the field in the MySQL database was set to "tinyint" instead of "char". $p3=$('#phone3').val(); worked fine once the MySQL field type was corrected!

OTHER TIPS

try to store to a variable like this.

var phone = $('#phone3').val();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top