Last active
August 29, 2015 14:05
-
-
Save Uriel29/99b69df9ddf554cbb779 to your computer and use it in GitHub Desktop.
Script para Validar URL em campos do seblod (mainbody.php )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// No Direct Access | |
defined( '_JEXEC' ) or die; | |
?> | |
<?php echo $cck->renderField('link'); ?> //exemplo de campo para por o link | |
<?php echo $cck->renderField('campo2'); ?> //quando usuário clicar no campo2 JS vai avisar se estiver errado o link. | |
<?php echo $cck->renderField('enviar'); ?> | |
//OBS o ID css de do campo link é #link e o id do campo2 é #campo2 | |
<script type="text/javascript"> | |
jQuery(function() { | |
jQuery('#campo2').click(function() { | |
var txt =jQuery('#link').val(); | |
var re = /([http://|https://]+[\w-]+\.)+[\w-]+(\[\?%&=]*)?/ | |
if (re.test(txt)) { | |
//alert('Valid URL') | |
} | |
else { | |
alert('Link incorreto! Sempre use "http://"'); | |
return false; | |
} | |
}) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment