1
I’m trying to call a function Javascript through the OnClientClick
.
The problem is that when running in the browser it does not validate the fields, it is as if the function was simply not called.
Javascript:
function VerificaCampos() {
//verifica processo
var ddlprocesso = document.getElementById("<%=ddlProcesso.ClientID%>")
if (ddlempresa.options[ddlprocesso.selectedIndex].value == ""){
alert("Favor preencher processo!");
ddlprocesso.focus();
return false;
Knob:
<asp:Button ID="btnBuscar" runat="server" CssClass="botao"
Text="Gerar" OnClientClick="if(VerificaCampos()) return false;"
OnClick="btnBuscar_Click"/>
You even put an Alert inside the function to see if it is called?
– Caique Romero
If your role is in a file
.js
will not work the part ofasp.net
:<%=ddlProcesso.ClientID%>
. You can confirm if you are in a file or on the same page.aspx
? Second, as @Caiqueromero commented, validated if you are entering Function, using aalert
orconsole.log
?– Ricardo Pontual
@Robervalvenicio Did it?
– Leandro Angelo