Imposer un minimum de caractères dans la description Mosets

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Imposer un minimum de caractères dans la description Mosets

Re: Imposer un minimum de caractères dans la description Mos

par explozpr » 15 mars 2013, 14:45

Merci pour vos réponse,

Je connais le HTML et CSS mais en ce qui concerne le PHP c'est vraiment pas ma tasse de thé, pourriez-vous me dire ou pourrais-je rajouter ce code php, j'ai peu etre une idée il s'agit peu être du fichier du formulaire de soumission de site dont voici le code : ( et voici à quoi correspond ce code : Page de soumission )
<script language="javascript" type="text/javascript" src="<?php echo $this->jconf['live_site'] . $this->mtconf['relative_path_to_js_library']; ?>"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->jconf['live_site']; ?>/components/com_mtree/js/category.js"></script>
<script language="javascript" type="text/javascript" src="<?php echo $this->jconf['live_site']; ?>/components/com_mtree/js/addlisting.js"></script>
<?php if( $this->mtconf['allow_imgupload'] && $this->mtconf['images_per_listing'] > 0 ) 
{
?><script language="javascript" type="text/javascript" src="<?php echo $this->jconf['live_site']; ?>/components/com_mtree/js/jquery-ui-1.8.16.custom.min.js"></script>	<?php
} 
if( $this->mtconf['use_map'] == 1 ) 
{ 
?><script language="javascript" type="text/javascript" src="<?php echo $this->jconf['live_site']; ?>/components/com_mtree/js/map.js"></script><?php
}
?>

<script language="javascript" type="text/javascript">
	jQuery.noConflict();
	var mosConfig_live_site=document.location.protocol+'//' + location.hostname + '<?php echo ($_SERVER["SERVER_PORT"] == 80) ? "":":".$_SERVER["SERVER_PORT"] ?><?php echo substr($_SERVER["PHP_SELF"],0,strrpos($_SERVER["PHP_SELF"],"/")); ?>';
	var active_cat=<?php echo $this->cat_id; ?>;
	var attCount=0;
	var attNextId=1;
	var maxAtt=<?php echo $this->mtconf['images_per_listing']; ?>;
	var msgAddAnImage = '<?php echo addslashes(JText::_( 'Add an image' )) ?>';
	var txtRemove = '<?php echo addslashes(JText::_( 'Remove' )) ?>';
	
	function submitbutton(pressbutton) {
		var form = document.adminForm;
		if (pressbutton == 'cancel'){submitform( 'viewlink' );return;}
		if (form.link_name.value == ""){
			alert( "<?php echo addslashes(JText::_( 'Please fill in link name' )) ?>" );
			<?php
			$editor = &JFactory::getEditor();
			$requiredFields = array();
			$this->fields->resetPointer();
			while( $this->fields->hasNext() ) {
				$field = $this->fields->getField();
				if(!in_array($field->name,array('link_hits','link_votes','link_rating','link__featured'))) {
					if( ($field->isRequired() && !in_array($field->name,array('link_name','link_desc'))) || ($field->isRequired() && $this->mtconf['use_wysiwyg_editor'] == 0 && $field->name == 'link_desc') ) {
						if( $field->isFile() )
						{
							echo "\n";
							echo '} else if (';
							echo 'isEmpty(\'' . $field->getName() . '\')';
							echo ' && ';
							echo '(';
							echo '(typeof form.'.$field->getKeepFileName().' == \'undefined\')';
							echo '||';
							echo '(typeof form.'.$field->getKeepFileName().' == \'object\' && form.'.$field->getKeepFileName().'.checked == false)';
							echo ')';
							echo ') {'; 
							echo "\n";
							echo 'alert("' . addslashes(JText::_( 'Please complete this field' ) . $field->caption) . '");';
						}
						else
						{
							echo '} else if (isEmpty(\'' . $field->getName() . '\')) {'; 
							echo 'alert("' . addslashes(JText::_( 'Please complete this field' ) . $field->caption) . '");';
						}
					}
					if($field->hasJSValidation()) {
						echo "\n";
						echo $field->getJSValidation();
					}
				}
				$this->fields->next();
			}
			?>
		} else {
			<?php
			if($this->mtconf['use_wysiwyg_editor'] == 1 && !is_null($this->fields->getFieldById(2))) {
				echo $editor->save( 'link_desc' );
			}
			if( $this->mtconf['allow_imgupload'] && $this->mtconf['images_per_listing'] > 0 ) {
			?>
			var hash = jQuery("#sortableimages").sortable('serialize');
			if(hash != ''){document.adminForm.img_sort_hash.value=hash;}
			<?php } ?>
			form.task.value=pressbutton;
			if(attCount>0 && checkImgExt(attCount,jQuery("input:file[name|='image[]']"))==false) {
				alert('<?php echo addslashes(JText::_( 'Please select a jpg png or gif file for the images' )) ?>');
				return;
			} else {
				form.submit();
			}
		}
	}
</script>

 
<h2 class="contentheading"><?php echo ($this->link->link_id) ? JText::_( 'Edit listing' ) : 	JText::_( 'Add listing' ); ?></h2>

<form action="<?php echo JRoute::_("index.php") ?>" method="post" enctype="multipart/form-data" name="adminForm" id="adminForm">
<table width="100%" cellpadding="0" cellspacing="4" border="0" align="center" id="editForm">
	
	<?php echo ( (isset($this->warn_duplicate) && $this->warn_duplicate == 1) ? '<tr><td colspan="2">' . JText::_( 'There is already a pending approval for modification' ) . '</td></tr>' : '' )?>
	
	<tr><td colspan="2" align="left">
		<input type="button" value="<?php echo JText::_( 'Submit listing' ) ?>" onclick="javascript:submitbutton('savelisting')" class="button" /> <input type="button" value="<?php echo JText::_( 'Cancel' ) ?>" onclick="history.back();" class="button" />
	</td></tr>
	<tr valign="bottom">
		<td width="20%" align="left" valign="top"><?php echo JText::_( 'Category' ) ?>:</td>
		<td width="80%" align="left" colspan="2">
			<?php if($this->mtconf['allow_changing_cats_in_addlisting']) { ?>
			<ul class="linkcats" id="linkcats">
			<li id="lc<?php echo $this->cat_id; ?>"><?php echo $this->pathWay->printPathWayFromCat_withCurrentCat( $this->cat_id, '' ); ?></li>
			<?php
			if ( !empty($this->other_cats) ) {
				foreach( $this->other_cats AS $other_cat ) {
					if ( is_numeric( $other_cat ) ) {
						echo '<li id="lc' . $other_cat . '">';
						if($this->mtconf['allow_user_assign_more_than_one_category']) {
							echo '<a href="javascript:remSecCat('.$other_cat.')">'.JText::_( 'Remove' ).'</a>';
						}
						echo $this->pathWay->printPathWayFromCat_withCurrentCat( $other_cat, '' ) . '</li>';
					}
				}
			}
			?>
			</ul>
			<a href="#" onclick="javascript:togglemc();return false;" id="lcmanage"><?php echo JText::_( 'Manage' ); ?></a>
			<div id="mc_con">
			<div id="mc_selectcat">
				<span id="mc_active_pathway"><?php echo $this->pathWay->printPathWayFromCat_withCurrentCat( $this->cat_id, '' ); ?></span>
				<?php echo $this->catlist; ?>
			</div>
			<input type="button" class="button" value="<?php echo JText::_( 'Update category' ) ?>" id="mcbut1" onclick="updateMainCat()" />
			<?php if($this->mtconf['allow_user_assign_more_than_one_category']) { ?>
			<input type="button" class="button" value="<?php echo JText::_( 'Also appear in this categories' ) ?>" id="mcbut2" onclick="addSecCat()" />
			<?php } ?>
			</div>
			<?php } else {
			
				echo $this->pathWay->printPathWayFromCat_withCurrentCat( $this->cat_id, '' );
				
			} ?>
		</td>
	</tr>
	<?php
	$this->fields->resetPointer();
	while( $this->fields->hasNext() ) {
		$field = $this->fields->getField();
		if($field->hasInputField()) { 
			
                        echo '<tr><td valign="top" align="left">';
			if($field->getCaption() != false) {
				if($field->isRequired()) {
					echo '<strong>' . $field->getCaption() . '</strong>:';
				} else {
					echo $field->getCaption() . ':';
				}
			}
			echo '</td><td align="left">';
			echo $field->getModPrefixText();
			echo $field->getInputHTML();
			echo $field->getModSuffixText();
			echo '</td></tr>';
                        
		}
		$this->fields->next();
	

        }
	?>
 
</table>
<table width="100%" cellpadding="0" cellspacing="0">
<?php if( $this->mtconf['use_map'] == 1 ) { ?>
<tr><td>
	<div id="mapcon">
	<h3 class="title"><?php echo JText::_( 'Map' ); ?></h3>

	<?php
	$width = '100%';
	$height = '200px';
	?>
	<script src="http://maps.googleapis.com/maps/api/js?v=3.6&sensor=false" type="text/javascript"></script>
	<script type="text/javascript">
		var map = null;
	    	var geocoder = null;
		var marker = null;
		var infowindow = null;
		var defaultCountry = '<?php echo addslashes($this->mtconf['map_default_country']); ?>';
		var defaultState = '<?php echo addslashes($this->mtconf['map_default_state']); ?>';
		var defaultCity = '<?php echo addslashes($this->mtconf['map_default_city']); ?>';
		var defaultLat = '<?php echo addslashes($this->mtconf['map_default_lat']); ?>';
		var defaultLng = '<?php echo addslashes($this->mtconf['map_default_lng']); ?>';
		var defaultZoom = <?php echo addslashes($this->mtconf['map_default_zoom']); ?>;
		var linkValLat = '<?php echo $this->link->lat; ?>';
		var linkValLng = '<?php echo $this->link->lng; ?>';
		var linkValZoom = <?php echo ($this->link->zoom)?$this->link->zoom:$this->mtconf['map_default_zoom']; ?>;
	</script>
	<div style="padding:4px 0; width:95%"><input type="button" onclick="locateInMap()" value="<?php echo JText::_( 'Locate in map' ); ?>" name="locateButton" id="locateButton" /><span style="padding:0px; margin:3px" id="map-msg"></span></div>
	<div id="map" style="width:<?php echo $width; ?>;height:<?php echo $height; ?>"></div>
	<input type="hidden" name="lat" id="lat" value="<?php echo $this->link->lat; ?>" />
	<input type="hidden" name="lng" id="lng" value="<?php echo $this->link->lng; ?>" />
	<input type="hidden" name="zoom" id="zoom" value="<?php echo $this->link->zoom; ?>" />
	
</div>
</td></tr>
<?php 
}

if( $this->mtconf['allow_imgupload'] && $this->mtconf['images_per_listing'] > 0 ) { ?>
<tr><td>
	<div id="imagescon">
	<h3 class="title"><?php echo JText::_( 'Images' ) ?></h3>
	<span><small><?php echo JText::_( 'Drag to sort images, deselect checkbox to remove.' ); ?></small></span>
	<ol id="sortableimages"><?php
	foreach( $this->images AS $image ) {
		echo '<li id="img_' . $image->img_id . '">';
		echo '<input type="checkbox" name="keep_img[]" value="' . $image->img_id . '" checked />';
		echo '<a href="' . $this->jconf['live_site'] . $this->mtconf['relative_path_to_listing_medium_image'] . $image->filename . '" target="_blank">';
		echo '<img border="0" style="position:relative;border:1px solid black;" align="middle" src="' . $this->jconf['live_site'] . $this->mtconf['relative_path_to_listing_small_image'] . $image->filename . '" alt="' . $image->filename . '" />';
		echo '</a>';
		echo '</li>';
	}
	?>
	</ol>
	<ol id="uploadimages">
	</ol>
	<div class="actionimages">
		<a href="javascript:addAtt();" id="add_att"><?php if(count($this->images) < $this->mtconf['images_per_listing']) { ?><?php echo JText::_( 'Add an image' ) ?><?php } ?></a>
		<?php if( $this->image_size_limit > 0 ) { ?>
		<br /><small><?php echo sprintf( JText::_( 'Limit of x per image' ), $this->image_size_limit )?></small>
		<?php } ?>
	</div>
</div>
<input type="hidden" name="img_sort_hash" value="" />
</td></tr>
<?php } ?>
<tr><td align="left">
	<br />
	<input type="hidden" name="option" value="<?php echo $this->option ?>" />
	<input type="hidden" name="task" value="savelisting" />
	<input type="hidden" name="Itemid" value="<?php echo $this->Itemid ?>" />			
	<?php if ( $this->link->link_id == 0 ) { ?>
	<input type="hidden" name="cat_id" value="<?php echo $this->cat_id ?>" />
	<?php } else { ?>
	<input type="hidden" name="link_id" value="<?php echo $this->link->link_id ?>" />
	<input type="hidden" name="cat_id" value="<?php echo $this->cat_id ?>" />
	<?php } ?>
	<input type="hidden" name="other_cats" id="other_cats" value="<?php echo ( ( !empty($this->other_cats) ) ? implode(', ', $this->other_cats) : '' ) ?>" />
	<?php echo JHTML::_( 'form.token' ); ?>
	<input type="button" value="<?php echo JText::_( 'Submit listing' ) ?>" onclick="javascript:submitbutton('savelisting')" class="button" /> <input type="button" value="<?php echo JText::_( 'Cancel' ) ?>" onclick="history.back();" class="button" />
</td></tr>
</table>
</form>

Re: Imposer un minimum de caractères dans la description Mos

par dunbar » 14 mars 2013, 21:30

Salut,

Une piste rapide
<?php
$min = 5;
$max = 20;

$chaine = "Voici";

$taille = strlen($chaine);


if( ($taille >= $min) && ($taille <= $max) )
{
	echo 'OK';
}
else
{
	echo 'Pas ok';
}


?>

Re: Imposer un minimum de caractères dans la description Mos

par cachouet » 14 mars 2013, 18:07

je sais pas trop comment ça marche avec les CMS mais tu pourrais tester comme ça,

dans input tu devrais ajouter:

pattern="[A-Za-z][0-9]{400,500}"

Imposer un minimum de caractères dans la description Mosets

par explozpr » 14 mars 2013, 12:05

Bonjour,

Je suis administrateur de l'annuaire de site web http://www.exploz-pr.com et je rencontre un problême, je n'arrive pas as imposer aux visiteurs souhaitant inscrire leurs sites via le Formulaire de soumission, d'écrire un minimum de tant de caractères dans la description avant que ceux-ci valident leur formulaire. Par exemple j'aimerais leur imposer une description de 400 caractères.

J'utilise le cms joomla couplé au composant "Mosets Tree" et leur assistance ne peut résoudre ce problème.

Voici une première capture d'écran qui montre les paramètres disponibles pour le champ "Description" : ( Cliquez pour agrandir )
Image

Je peux imposer une limite maximum de caractères mais pas minimum !

J'ai beau faire des recherches, je ne trouve quasiment rien sur ce sujet, j'ai trouvé CECI qui parle de mettre un minimum de 5 caractères pour le champ "name".

J'ai plusieurs fichiers php qui m'interpellent plus que d'autres, je vous les fournis en esperant que cela vous serves. http://ul.to/5oblx6ka et http://ul.to/3kgn3ks9

Voila, merci d'avance pour ceux ou celles qui se pencheront sur mon problème.