Skip to main content
Inspiring
August 11, 2022
Question

CFINPUT mask

  • August 11, 2022
  • 4 replies
  • 673 views

Bonjour,

J'ai bien compris le fonctionnement quand on connait le nombre déléments :

<CFINPUT type="text" name="Iban1" mask="??00" size="4" maxlength="4">

Par contre, je n'ai pas compris quand on connait pas la longeur à l'avance :

Exemple : 0.50 ou 2.25 ou 65.85 ou 357 ou 1 253.35.

D'autre existe-t-il un moyen pour empécher de saisir dans un champ suite à une condition non remplie.

Merci d'avance pour votre aide.

 

Hello,

I understand how it works when you know the number of elements:

<CFINPUT type="text" name="Iban1" mask="??00" size="4" maxlength="4">

On the other hand, I did not understand when we do not know the length in advance:

Example: 0.50 or 2.25 or 65.85 or 357 or 1,253.35.

Else is there a way to prevent typing in a field following an unfulfilled condition.

thank you in advance for your help.

 

 

This topic has been closed for replies.

4 replies

BKBK
Community Expert
Community Expert
August 21, 2022

If you don't know the length in advance, a mask will then be irrelevant. At least, that is what I think.

 

You mentioned Javascript. I would recommend using it to validate the input. 

 

Let's assume you wish to validate IBAN bank-accounts. The following Javascript provides a simple example to start with.

<cfif isDefined("form.fieldnames")>
	<cfdump var="#form#" >
</cfif>

<cfform name="myForm" action="#CGI.SCRIPT_NAME#" onsubmit="return validateIbanForm()" method="post">
IBAN1: <cfinput type="text" name="Iban1" size="27" maxlength="27">
<cfinput type="submit" value="Submit" name="sbmt">
</cfform>

<script type="text/javascript">
function validateIbanForm() {
 	var iban = document.forms["myForm"]["Iban1"].value.trim();
  	if (iban == "") {
    	alert("The field may not be blank. You must enter your IBAN");
    	return false;
  	}
  	/* In France, for example, an IBAN has 27 characters. */
  	if (iban.length != 27) {
    	alert("You must enter a valid IBAN");
    	return false;
  	}
  	return true
}
</script>


 

ZNBAuthor
Inspiring
September 1, 2022

Bonjour,

Je voudrais, si cela est possible que les sommes s'affichent :

1253.23 en 1 253.23!

mais je peux aussi avoir une somme plus importante ou moins importante :

125234.56 en 125 234.56  ou 0.23 en 0.23.

Merci par avance.

ZNBAuthor
Inspiring
September 3, 2022

HELP

Pas de réponse ?

Merci par avance

ZNBAuthor
Inspiring
August 20, 2022

Bonjour,
La reflexion " Essayez peut-être de reformuler une fois de plus. 🙂" n'est pas gentille et surtout ... n'apporte rien.
D'autre part, je n'ai pas de réponse à mes 2 questions que je reformule :
1 - mask quand on connait pas la longeur à l'avance ( Exemple : 0.50 ou 2.25 ou 65.85 ou 357 ou 1 253.35.)
2 - est-il possible d'empécher une saisie quand une condition n'est pas remplie (peut-etre en javascript).
Merci de l'aide

 

Hello,

The reflection "Maybe try to rephrase one more time. :smiling_face_slightly:" is not nice and above all ... does not add anything. On the other hand, I have no answer to my 2 questions that I rephrase:

  1.  mask when we don't know the length in advance (Example: 0.50 or 2.25 or 65.85 or 357 or 1 253.35.)
  2.  is it possible to prevent an input when a condition is not met (maybe in javascript).

Thanks for the help

 

Charlie Arehart
Community Expert
Community Expert
August 13, 2022

Well,  when you say "prevent", that implies validation--which you're not doing. As far as I know,  the mask just controls display of values as people type. That said,  you show using maxlength,  and that WOULD prevent the browser from letting you type more than 4 characters.

 

Maybe try rewording one more time. 🙂 

/Charlie (troubleshooter, carehart. org)
ZNBAuthor
Inspiring
August 19, 2022

Hello ! 

Personne n'a d'idées ? 

Merci par avance.

 

Hello !

Nobody has any ideas?

Thanks in advance.

BKBK
Community Expert
Community Expert
August 20, 2022

@ZNB , could you please first let us know your reaction to Charlie's comment?

ZNBAuthor
Inspiring
August 13, 2022

Hello ! 

Personne n'a d'idées ? 

Merci par avance.

 

Hello !

Nobody has any ideas?

Thanks in advance.