{"id":1355,"date":"2022-08-30T15:15:50","date_gmt":"2022-08-30T15:15:50","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/13\/livevalidation-js-custom-username-check-function-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:15:50","modified_gmt":"2022-08-30T15:15:50","slug":"livevalidation-js-custom-username-check-function-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/livevalidation-js-custom-username-check-function-collection-of-common-programming-errors\/","title":{"rendered":"livevalidation.js custom username check function-Collection of common programming errors"},"content":{"rendered":"<p>i am having the same issue. Ive found the following, http:\/\/forum.jquery.com\/topic\/ajax-return-value-on-success-or-error-with-livevalidation but have not been able to get it working. BUT YES! At this very moment i made som (crappy) javascript addon that made it behave, i think \ud83d\ude42<\/p>\n<p>This is what i use.<\/p>\n<pre> function check_avail(name, id, postUrl) { var dataVal = name+'='+$(id).val(); var isaccepted = '' $(id).next('div').remove(); $(id).after(\"<br \/>Unders\u00f8ger om \"+name+\" er ledigt\");\n\n       $.ajax({\n          url: postUrl,\n          cache: false,\n          type: 'post',\n          dataType: 'json',\n          data: dataVal,\n          async:  false,\n          success: function(data) {\n             if( data.success == 'true' )\n             {\n                $('#'+name+'-availability').remove();\n                \/\/return false;\n           isaccepted = false;\n             }\n\n             if( data.success == 'false' )\n             {\n                $('#'+name+'-availability').remove();\n    \/\/            name.destroy();\n            isaccepted = true;\n             }\n          }\n\n       });\n\n    if (isaccepted == false) {\n    return false;   \n    } else{\n    return true\n    };\n\n    }\n\n<\/pre>\n<p>And<\/p>\n<pre>\n\n    f1.add( Validate.Custom, { against: function() {\n     return check_avail( 'brugernavn', '#ft001', 'usernamecheck.asp' ); \n    }, failureMessage: 'Brugernavnet er optaget' } );\n\n<\/pre>\n<p>Hope it helps you \ud83d\ude42 The json query you can read about on the link in the begining \ud83d\ude42 (I am not at all skilled at javascript, and the &#8220;isaccepted&#8221; solution could problalby be made a lot better)<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-13 09:49:17. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>i am having the same issue. Ive found the following, http:\/\/forum.jquery.com\/topic\/ajax-return-value-on-success-or-error-with-livevalidation but have not been able to get it working. BUT YES! At this very moment i made som (crappy) javascript addon that made it behave, i think \ud83d\ude42 This is what i use. function check_avail(name, id, postUrl) { var dataVal = name+&#8217;=&#8217;+$(id).val(); var isaccepted [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1355","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1355","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1355"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1355\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1355"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1355"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1355"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}