Welcome Guest, Not a member yet? Register   Sign In
[solved] don't understand javascript variable scope; now talking about validation plugin
#7

[eluser]SPeed_FANat1c[/eluser]
I am using form validation plugin.

Edit: made a short version:
Code:
<scri+pt src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js" type="text/javascript"></scri+pt>
<s+cript  src="http://www.ylakiudarzelis.lt/js/jquery.validate.js" type="text/javascript"></s+cript>
<scr+ipt>
$(function(){
$('input.save').click(function() {
        
        $('form').attr( 'target', '' );
        
        valid = $(".edit").validate({        
            
            rules: {
                 input_pavadinimas: {
                  required: true,
                  maxlength: 20,
                
                remote:  "http://www.ylakiudarzelis.lt/admin_/info_psl/name_check_ajax"
                }                
            }
        
            
        }
                
        
        ).form();
        //alert('');
        if(valid)
            alert('valid');
        else alert('not valid');
            //document.myform.submit();
    });

    
});

</scr+ipt>

&lt;form action="http://www.ylakiudarzelis.lt/test/valid" method="post" class="wide edit" name="myform"&gt;
    
    
        <br /><label for="label">Puslapio pavadinimas:*</label>
&lt;input type="hidden" name="name" value="asdasd" /&gt;
&lt;input type="text" name="input_pavadinimas" value="asdasd" maxlength="20" size="10" style="width:20%"  /&gt;&lt;br /><br />        
         <br>
        
        &lt;input class = "save" type="button" value="Išsaugoti" /&gt;
    
    
&lt;/form&gt;

php validation always echoes false
Code:
function name_check_ajax()
    {
        echo 'false';
    }


When I run this code, I get an alert "valid" and after alert the message appeards near input field - "Please fix this field."

What do I need to change there so the variable "valid" could be set to false?


Messages In This Thread
[solved] don't understand javascript variable scope; now talking about validation plugin - by El Forum - 01-26-2011, 01:38 AM



Theme © iAndrew 2016 - Forum software by © MyBB