Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Javascript set button enable on checkbox true
Message
De
20/10/2010 14:32:04
Timothy Bryan
Sharpline Consultants
Conroe, Texas, États-Unis
 
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Versions des environnements
Environment:
C# 4.0
Application:
Web
Divers
Thread ID:
01485567
Message ID:
01486366
Vues:
27
>>
>>The next one I am trying to do is enabling a "Continue" button when all three of the userID, Password, and retype password textboxs have been filled out or validated client side. Basically I do not want them to continue until I have valid values in all three boxes and the two passwords match. How would you approach this? I am adding jQuery into this project now.
>
>The easiest might be to hook into the lost focus event of the controls and do the validation there. If you want to display an error message (to let them know their passwords don't match) then you'll want to add something like a div section with the message and hide or show it selectively. Something like this:
>
>
>        <script type="text/javascript"
>            $(document).ready(function () {
>                $("#<%= this.txtUsername.ClientID %").blur(validatePassword);
>                $("#<%= this.txtPassword.ClientID %").blur(validatePassword);
>                $("#<%= this.txtRetypePassword.ClientID %").blur(validatePassword);
>            });
>
>            function validatePassword() {
>                var username = $("#<%= this.txtUsername.ClientID %").val();
>                var password = $("#<%= this.txtPassword.ClientID %").val();
>                var retype = $("#<%= this.txtRetypePassword.ClientID %").val();
>                var empty = (username.length == 0) || (password.length == 0) || (retype.length == 0);
>
>                var valid = !empty && (password == retype);
>
>                if (!empty && !valid) {
>                    $("#password").show();
>                }
>                else {
>                    $("#password").hide();
>                }
>
>                $("#txtLogin").attr('disabled', !valid);               
>            }
>        </script
>
>        <div id="password" style="display:none;"The entered passwords do not match.</div
>
Thanks a bunch Paul, this is helpful.. I also found this Validation plug in for jquery that is really nice.
http://docs.jquery.com/Plugins/Validation
Problem is I cannot figure out how to get a script or a script source into my page from the user control. I tried a RadCodeBlock and thought that was supposed to work but it does not. I also tried this in the OnInit
Page.ClientScript.RegisterClientScriptResource(GetType(), "~/scripts/EnrollmentValidation.js");
Since I am using Telerik, there is a RadScriptManager on the outside Master page but it doesn't appear I can register a script with the script manager since it is in the master.
Tim
Timothy Bryan
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform