Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

269
Visualizações
When im submitting the button its showing popup message but also saving in the data base

// This is my js file function validate() {

var z = document.forms["form1"]["sponsorid"].value;
if (!z.match(/^\d+/)) {
    alert("Sponsor id should be in Numbers only")
    return false
}
var z2 = document.forms["form1"]["clientname"].value;
if (!z2.match(/^[a-zA-Z_ ]+$/)) {
    alert("Client Name should be in Alphabets only")
    return false
}
var z3 = document.forms["form1"]["additionalnumber"].value;
if (!z3.match(/^\d+/)) {
    alert("Additional Number should be in Numbers only")
    return false
}
var z4 = document.forms["form1"]["district"].value;
if (!z4.match(/^[a-zA-Z_ ]+$/)) {
    alert("District should be in Alphabets only")
    return false
}
var z5 = document.forms["form1"]["mainownerid"].value;
if (!z5.match(/^\d+/)) {
    alert("Main Owner ID should be in Numbers only")
    btnsave.Click(false)
}
var z6 = document.forms["form1"]["sponsorname"].value;
if (!z6.match(/^[a-zA-Z_ ]+$/)) {
    alert("Sponsor Name should be in Alphabets only")
    return false
}
var z7 = document.forms["form1"]["mobileno"].value;
if (!z7.match(/^\d+/)) {
    alert("Mobile Number should be in Numbers only")
    return false
}
var z8 = document.forms["form1"]["emailid"].value;
if (!z8.match(/\S+@\S+\.\S+/)) {
    alert("Enter correct Email Id")
    return false
}
var z9 = document.forms["form1"]["phoneno"].value;
if (!z9.match(/^\d+/)) {
    alert("Phone Number should be in Numbers only")
    return false
}
return true

}

//This is my vb file Protected Sub btnsave_Click(sender As Object, e As ImageClickEventArgs) Handles btnsave.Click

    Dim con As SqlConnection = New SqlConnection(constring)

....content... End Sub

//This is in my aspx file <asp:ImageButton ID="btnsave" runat="server" ImageUrl="~/images/save.gif" TabIndex="02" OnClientClick="validate()" />

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

If I well understand your problem consist in submitting in a wrong case of validation. Means you wont want to submit if validation returns false. If so, you have to specify the default button of submit action on your form. A piece of code for “how to”:

pay attention on defaultbutton="Button1"

<form id="form1" runat="server" defaultbutton="Button1"  
  <%--other code here--%>
  <asp:Button ID="Button1" runat="server" Text="Button" Visible="False" />
</form>
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda