I have used the script at:
http://www.javascript-coder.com/
i use the following jquery code in which i am calling its methods.
$("form[开发者_如何转开发name='registeruser'] input[name='register']").live('click',function(){
//validateregister($("form[name='registeruser']"));
var frmvalidator = new Validator("registeruser");
frmvalidator.addValidation("name","req");
});
my form "registeruser" is loading in a popup. When i click register button, nothing happens for the text field "name".
Help me with this
ok problem was that i was using a simple button to submit the form. which is not allowed in this script. I have to change the button to a submit button.
and i you really want to use a simple button instead of submit button, then following code can be used
in your form
<input type="button" value="submit" name="register" />
in your jquery
$("#registeruser input[name='register']").live('click',function(){
//check if form 'registeruser' is valid or not
if($("#registeruser").valid())
{
alert("ok");
}
else
{
jQuery.validator.messages.required = "";
$("#registeruser").validate({
errorClass: "requiredfields",
highlight: function(element, errorClass, validClass) {
$(element).addClass(errorClass).removeClass(validClass);
},
unhighlight: function(element, errorClass, validClass) {
$(element).removeClass(errorClass).addClass(validClass);
},
errorPlacement: function(error,element) {}
});
}
精彩评论