Good afternoon everyone.
I must say at the beginning that it is my first question here. I usually just read the questions of others, but I do not find a solution to this problem anywhere on the internet.
I have a code that takes a value from a field in html. I want to use a jQuery object in a jQuery property, but I do not know how to do it.
The point is I want to put a ZIP code mask in place, and the dash ('99999-999') cuts the numerical value of the zip to the first 5 digits. After going far behind, I made the following code to be able to take this stroke out of the move and only play with the zip numbers, but for some reason it does not work. Here's what I did:
var cep = parseInt($('#ip-cep').val.toString().replace(/-/, ''), 10);
Just to clarify, I get the value of the html field, transform it into a string, retreat the trace with .replace (), and then convert it back to numeral to make the comparisons. The point is it does not work. The value of 'cep' always returns as NaN, even with numerical values only. If I took out the trace with replace, when parseInt goes into action there should only be numbers in place to be converted, since the mask only allows the user to type numbers.
What am I doing wrong? Thank you for your attention.