Jump to content
Fórum Script Brasil
  • 0

Validação Formulário ASP + Jquery


s3c0
 Share

Question

Caros amigos,

 

boa tarde. Feliz Ano a todos!

 

Estou tentando montar um cadastro de e-mail. Peguei um script na internet e não estou conseguindo adaptar no meu "sistema".

 

index.html

<form class="znhost-validator ajax" action="newsletter.asp" method="post">
    <div class="col-md-8">
    
    <input type="hidden" class="form-control required" name="nome" value="site" placeholder="digite seu nome" data-alert="Nome" />
    <input type="text" class="form-control required znhost-email-mask" name="email" value="" placeholder="digite seu e-mail" data-alert="E-mail" />
    </div>
    <div class="col-md-1">
    <button name="receba-news" class="btn btn-default" type="submit">OK</button>
    </div>
    <div class="col-md-8 col-md-offset-3">
    <div class="alert alert-danger main-alert displaynone" data-alert="Preencha o(s) campo(s):"></div>
    <div class="alert alert-success form-success displaynone"></div>
    </div>
    </form>

script.js

<script>
function validateForm(form){
if(form.hasClass('znhost-validator')){
    var valid=true;var fields="";
    if(form.find('.check-validator').length>0){
        form.find('.check-validator').each(function(){
            if($(this).find('input:checked').length<1){
                valid=false;if($(this).attr('data-alert')!=""){
                fields+='<li>- <strong>'+$(this).attr('data-alert')+'</strong></li>';}
$(this).addClass('not-valid');}});}
if(form.find('.required').length>0){
    form.find('.required').each(function(){
        if($(this).val()==""||$(this).val()==undefined){
            valid=false;if($(this).attr('data-alert')!=""){
            fields+='<li>- <strong>'+$(this).attr('data-alert')+'</strong></li>';}
$(this).parent().parent().addClass('has-error');}
    else if(!!$(this).attr('data-confirm')){
        if($(this).val()!=form.find($(this).attr('data-confirm')).val()){
        valid=false;fields+='<li>- <strong>'+$(this).attr('data-confirm-alert')+'</strong></li>';$(this).parent().parent().addClass('has-error');}}});}
if(valid==false){form.find('.form-success').slideUp();form.find('.main-alert').html('');form.find('.main-alert').append('<p><span class="glyphicon glyphicon-warning-sign"/>'+form.find('.main-alert').attr('data-alert')+'</p>');form.find('.main-alert').append('<ul>'+fields+'</ul>');form.find('.main-alert').fadeIn();form.find('.not-valid .alert').fadeIn();return false;}else{return true;}}else{return true;}}
</script>

newsletter.asp

<%



Response.write ("{""nome"":"""&request("nome")&""",""email"":"""&request("email")&"""}") 




%>

 

Já tentei de tudo, porém só te retorna erro. "Erro, Tente Novamente".

 

Alguém consegue me dar um help?

 

Abraços

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Olá @bareta, não possui nenhum arquivo a mais, somente esses.

 

Pelo que entendi, o Arquivo ASP recebe os dados verifica se existe ou não e retorna o resultado, porém não estou sabendo retornar os valores para serem validados no js.

 

Abraços

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



  • Forum Statistics

    • Total Topics
      149.6k
    • Total Posts
      646.1k
×
×
  • Create New...