patch for jquery url validator working

This commit is contained in:
asus
2024-02-18 02:27:09 +01:00
parent daaf6a8a42
commit ee2dafbccc
5 changed files with 11 additions and 29 deletions

View File

@@ -1,4 +1,3 @@
console.log("-------------EXAMPLEEEEE----------------- :)");
console.log("PLGNTLS_data:");
console.log(PLGNTLS_data);

View File

@@ -1,20 +0,0 @@
console.log("-------------jquery----------------- :)");
// https://stackoverflow.com/questions/24938890/wordpress-jquery-noconflict
// https://wordpress.stackexchange.com/questions/104510/how-to-add-jquery-script-to-an-individual-page
// https://developer.wordpress.org/reference/functions/wp_enqueue_script/#jQuery_noConflict_Wrappers
//(function($) {
jQuery( document ).ready( function( $ ) {
$.validator.addMethod
(
'validUrl',
function(value, element)
{
var url = $.validator.methods.url.bind(this);
return url(value, element) || url('http://' + value, element);
},
'Please enter a valid URL'
);
} );
//})(jQuery);

View File

@@ -0,0 +1,8 @@
// https://stackoverflow.com/questions/12741517/how-to-make-url-validation-without-http-or-add-it-after-validation-passed/44848476#44848476
let old_url = jQuery.validator.methods.url;
jQuery.validator.addMethod( 'url', function(value, element) {
let url = old_url.bind(this);
return url(value, element) || url('http://' + value, element);
}, 'Please enter a valid URL'
);