I cannot call Javascript function in textbox

Asked

Viewed 692 times

0

I have the following java script function to format my date fields:

function MascaraData(data){
if(mascaraInteiro(data)==false){
    event.returnValue = false;
    }   
return formataCampo(data, '00/00/0000', event);
}

but I cannot call the function in my page’s textbox

meu campo TextBox data inicio

  • If possible, include messages from your browser console in the question :)

  • Have you considered using jQuery.Mask() ?

  • $("#Textboxdatainicio"). Mask("99/99/9999");

  • With Asp or input?

2 answers

2

I decided as follows:

onKeyUp="MascaraData(this)"

0

try like this.

<input type="text" onkeypress="MascaraData();" id="TextBoxDataInicio" />



function MascaraData() {

    TextBoxDataInicio = document.getElementById("TextBoxDataInicio");
    data = TextBoxDataInicio.value;

    if (mascaraInteiro(data) == false) {
        event.returnValue = false;
    }
    TextBoxDataInicio.value = formataCampo(data, '00/00/0000', event);
}
  • if I switch to input, it will compromise some things I have here in the project. It has to be Asp: same.

  • The input was what I used for testing, to show that I would not need to pass "Form1.data". You can continue using Asp:Textbox

Browser other questions tagged

You are not signed in. Login or sign up in order to post.