[eluser]SPeed_FANat1c[/eluser]
Ok, I make a form this way:
Code:
$('a.add').live('click',function(){
$('.links').empty();
$('.add').addClass('grizti'); //pakeiciam klase ir uzrasa
$('.grizti').text('Grižti');
$('.grizti').removeClass('add');
//generate form
$('.links').html('<form id = "new" action="'+ CI.base_url + 'admin_/nuorodos/enter_new" method="post"><h3>Nauja nuoroda</h3>' +
'<label>Nuoroda*: </label><input type="text" name = "link_new" value="http://" /><span class = "errorSmall error_link"></span><br />' +
'<label>Trumpas apibūdinimas: </label><input type="text" name = "descr_new" value="" />' +
'<br><br><input type="submit" class = "submit" value="Išsaugoti" /></form>');
return false;
});
And the validation code;
Code:
$("#new").validate({
submitHandler:function(form) {
form.submit();
},
rules: {
link_new: {
required: true,
maxlength: 1000,
url: true
},
descr_new: {
maxlength: 300
}
},
messages: {
link_new:{
required: "Neįvedėte nuorodos"
}
}
});
So the first thing is - it does not validate url. When I tried to make the same form in view without need to click on a link with class "add" then it validates. So it does not validate only when I add it dinammically. Anybody knows how to solve this?
And anoter thing is - how to stop it from going to submit page when I click submit button? I don't want it to go to page - ajax should post the data from input fields.