$(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_date_start").onlyChars("\\d.: "); Calendar.setup({ inputField : "db_date_start", ifFormat : "%d.%m.%Y %H:%M", button : "db_date_start_button", singleClick : true, showsTime : true, firstDay : 1, timeFormat : "24" });$("#db_date_end").onlyChars("\\d.: "); Calendar.setup({ inputField : "db_date_end", ifFormat : "%d.%m.%Y %H:%M", button : "db_date_end_button", singleClick : true, showsTime : true, firstDay : 1, timeFormat : "24" });$("#db_org_phone").onlyChars("\\d +"); $("#editForm").validate({ rules: {db_name: {required: true}, db_date_start: {regexp: "\\d{1,2}\\.*\\d{1,2}\\.\\d{4} (\\d{1,2}(:\\d{1,2})?)?", required: true}, db_date_end: {regexp: "\\d{1,2}\\.*\\d{1,2}\\.\\d{4} (\\d{1,2}(:\\d{1,2})?)?", required: true}, db_town: {required: true}, db_org_phone: {regexp: "\\+?\\s*(\\d{3})?(\\s*\\d{3}){3}"}, db_org_email: {email: true}, db_org_web: {regexp: "((http|ftp|https):\\/\\/)?[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%\&:/~\\+#]*[\\w\\-\\@?^=%\&/~\\+#])?"}}, messages: {db_date_start: {regexp: "Datum je ve špatném formátu."}, db_date_end: {regexp: "Datum je ve špatném formátu."}, db_org_phone: {regexp: "Telefonní číslo je neplatné."}}, errorPlacement: db_error_placement_func }); }});