Click here to Skip to main content
15,913,487 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to do validation on client-side using JQuery?

Thanks in advance!
Posted
Updated 1-Mar-11 7:20am
v3

Please use the Validation plugin for jQuery to do that: http://docs.jquery.com/Plugins/validation[^].
That's the way to do clientside validation.

Hope that helps you.

Cheers!
 
Share this answer
 
Comments
fjdiewornncalwe 14-Feb-11 9:43am    
Of course this is the way to do it... +5.
Espen Harlinn 14-Feb-11 15:44pm    
Good link, the way to do it, my 5
As you are a beginner,please refer this site:

http://www.dotnetcurry.com/ShowArticle.aspx?ID=231[^]

Adding an example from there:

Example 1 – Display an alert on asp:Button click using jQuery
Add a Button element to the page as shown below:
<asp:button id="Button1" runat="server" text="Button" xmlns:asp="#unknown" />
Now in order to tell the browser to perform some action using jQuery as soon as the document is ready or loaded, use this block:

<script type="text/javascript">
        $(document).ready(function() { 
        // add code here
        });
    </script> 
Add your code in the function block

<script type="text/javascript">
        $(document).ready(function() {
        $("#Button1").click(function() {
            alert("Hello world!");
        });
 
        });
    </script>


Hope this helps!Please replace the alert with your respective validate method.
 
Share this answer
 
v2
Comments
Manfred Rudolf Bihy 14-Feb-11 10:51am    
What does your sample have to do with client side validation. Please explain. Thanks!
Anupama Roy 14-Feb-11 11:17am    
OP has not mentioned what sort of validation is looked for.This just shows how a validation function in client side can be called using jquery from button's click event so that OP gets an idea to do an implementation accordingly!
Manfred Rudolf Bihy 14-Feb-11 16:00pm    
I still don't get it. What exactly is being validated by your code? If your validation was to verify that "A button has been clicked", then let's call it validation.
Anupama Roy 14-Feb-11 23:34pm    
I appreciate your answer provided to the question.Has OP mentioned what needs to be validated for which you are asking me what is being validated by my code?No right?A possible scenario to call a validation function is under a button click(Submit/Save).From there OP has to call their validate function.I cant write it unless the scenario is provided.I very well know what the term validation mean.There might a different thinking from each person's perspective.If my answer missed out a line that instead of alert,call the respective validate method, then I accept it.
Manfred Rudolf Bihy 15-Feb-11 9:38am    
Now I understand what you meant to say, that's Ok. If the text to the alert method would have been "Put validation code here" it would have been clearer to me. :)
Hope this[^] might give you an Idea.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900