Skip to content

Instantly share code, notes, and snippets.

@Uriel29
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Uriel29/99b69df9ddf554cbb779 to your computer and use it in GitHub Desktop.
Save Uriel29/99b69df9ddf554cbb779 to your computer and use it in GitHub Desktop.
Script para Validar URL em campos do seblod (mainbody.php )
<?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