$(document).ready(function(){ if($("#editForm").length > 0){ $.validator.addMethod("regexp", function(value, element, param) { return !value.length || (new RegExp("^" + param + "$")).test(value); }); $.extend(jQuery.validator.messages, { required: "Údaj je povinný.", email: "E-mail je neplatný.", regexp: "Údaj je ve špatném formátu.", url: "URL adresa je neplatná." }); if(typeof(db_error_placement_func)=="undefined"){ function db_error_placement_func(error, element) { var elem = element.parent("td").slice(0,1); error.appendTo( elem ); } } $("#db_phone").onlyChars("\\d +"); $("#editForm").validate({ rules: {db_login: {required: true}, db_password_auth: {equalTo: "#db_password"}, db_password: {required: function(){ return $("#editForm").attr("action").match(/db_id=\d+/) == null; }}, db_name: {required: true}, db_surname: {required: true}, db_town: {required: true}, db_district: {required: true}, db_email: {email: true, required: true}, db_phone: {regexp: "\\+?\\s*(\\d{3})?(\\s*\\d{3}){3}"}, db_web: {regexp: "((http|ftp|https):\\/\\/)?[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%\&:/~\\+#]*[\\w\\-\\@?^=%\&/~\\+#])?"}, db_image: {regexp: "((http|ftp|https):\\/\\/)?[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%\&:/~\\+#]*[\\w\\-\\@?^=%\&/~\\+#])?"}}, messages: {db_password_auth: {equalTo: "Zadaná hesla se neshodují."}, db_phone: {regexp: "Telefonní číslo je neplatné."}}, errorPlacement: db_error_placement_func }); $('#db_antispcislo').val( parseInt($('input[name=db_antispcislo2]').val())-63 ); $('#antispamdb').hide(); }});