I have a problem. This fuction recive a textboxInput, (is called by two textbox), and I want to replace the user text with my restrictions. but I dont know how to replace the textbox to the textBoxInput
function validarRutPromise(textBoxInput) {
var textBox = textBoxInput.value; // the string in the textBoxInput
alert(textBox);
textBox = textBox.toUpperCase();
textBox = textBox.replace(".", "");
textBox = textBox.replace(".", "");
textBox = textBox.replace("-", "");
textBoxInput.value(textBox); --- This line doesnt work!
Im reading, but document.getElementById, or document.getElementByName doesnt match because, my textBoxInput have a dinamical name
and Y call the function by:
value
isn't a function, it's a property. Just assign it like you would any variable:
textBoxInput.value = textBox;
Aside:
You can simplify your replace()
calls with RegEx:
textBox = textBox.replace(/[-\.]+/, "");