Jump to content

Combine these 2 rules?


ksulliv1

Recommended Posts

Hi, I have a business card template where I would like to use the Change Phone Format rule along with a rule to limit total characters to 12. This would be for a phone number field of course and we only want users to enter a 10 digit phone number and only the two period symbols (not hyphens or spaces) so,

 

616.232.4455

 

The way the card is designed, the phone field is basically only wide enough to support the 12 total characters and, there is another field butted up next to it. So if someone were to enter +1 616.232.4455 for instance, it would shove the adjacent field down to another line below where it is supposed to be. so I would like to create a rule that uses a character limit,

 

return Left(Field("Phone"),12);

 

And the JS version of the phone format rule together so, first the field only accepts the first 12 characters entered and then it also formats it as shown above. Would this work and if so how do I join the two?

 

return Left(Field("Phone"),12);

 

And

 

var Var1 = "Phone";

var CaseSelection = "Format 1";

 

 

 

if(CaseSelection == "Format 1")

{

var formatStyle01 = "$1.$2"; //simple 7 digit phone

var formatStyle02 = "$1.$2.$3"; //simple 10 digit phone

var formatStyle03 = "+$1 $2.$3.$4"; //10 digit phone starts with 1

var formatStyle04 = "$1.$2.$3 ext.$4"; //10 digit phone with extension

var formatStyle05 = "+$1 $2.$3.$4 ext.$5"; //10 digit phone starts with 1 with extension

var formatStyle06 = "$1.$2 ext.$3"; //7 digit phone with extension

 

var thisNumber = Field(Var1);

 

return formatNumber(Trim(thisNumber));

}

Link to comment
Share on other sites

Hi, I have a business card template where I would like to use the Change Phone Format rule along with a rule to limit total characters to 12. This would be for a phone number field of course and we only want users to enter a 10 digit phone number and only the two period symbols (not hyphens or spaces) so,

 

616.232.4455

 

The way the card is designed, the phone field is basically only wide enough to support the 12 total characters and, there is another field butted up next to it. So if someone were to enter +1 616.232.4455 for instance, it would shove the adjacent field down to another line below where it is supposed to be. so I would like to create a rule that uses a character limit,

 

return Left(Field("Phone"),12);

 

And the JS version of the phone format rule together so, first the field only accepts the first 12 characters entered and then it also formats it as shown above. Would this work and if so how do I join the two?

Well, first of all, when you say you "want users to enter a 10 digit phone number," where are the users doing that? Is this in some kind of web application, such as MarcomCentral or DSF? If so, then you probably want to have some client-side data entry validation on the web form itself. If you're using DSF or a similar system, you can use the HTML Form Definition feature in FusionPro to set up a web form with a validation pattern. Other systems such as MarcomCentral allow you to define various validation formats for data entry fields via their own template setup screens. If you have a custom web app, you should use client-side JavaScript on the web page for validation.

 

Even if you aren't trying to change the way the built-in Change phone format Rule works, you still should do client-side validation of the form entries before sending the data to FusionPro. The rule is designed to work on already valid phone number data, and it doesn't attempt to validate the data format and handle bad entries. So the user can just enter nonsense like "foobar", and the rule will just spit that back out and you'll get that nonsense in the output. "Garbage in, garbage out," as we say.

 

That said, if you don't want the result to have a +1 at the beginning or an extension at the end, you can just modify the formats in the rule like so:

var formatStyle01 = "$1.$2"; 			//simple 7 digit phone
var formatStyle02 = "$1.$2.$3";			//simple 10 digit phone
var formatStyle03 = "$2.$3.$4";		//10 digit phone starts with 1
var formatStyle04 = "$2.$3";		//10 digit phone with extension
var formatStyle05 = "$2.$3.$4";	//10 digit phone starts with 1 with extension
var formatStyle06 = "$1.$2";		//7 digit phone with extension

Link to comment
Share on other sites

Thank you for the response. We use WebCRD from Rochester Software Associates as our web service, and I am not familiar with any offerings from them to limit characters on fields. I know there is a data pattern available in the FP HTML editor but, I haven't been able to figure out what should be entered there. Everything I try comes back with the error,

 

The pattern field should contain at least one of the following characters, #, A, * and ?

 

So I don't know how to lock it to use the data pattern to limit the characters. Can it be set to accept 12 total characters being numbers and periods, or just limit to 10 total numbers? And then apply the correct phone format rule in the text editor?

Link to comment
Share on other sites

We use WebCRD from Rochester Software Associates as our web service, and I am not familiar with any offerings from them to limit characters on fields.

 

Suggest contacting RSA's support group. I'd be surprised if WebCRD doesn't allow you to limit the amount of characters that your users can enter in a form field. This would be your easiest solution.

 

I know there is a data pattern available in the FP HTML editor but, I haven't been able to figure out what should be entered there. Everything I try comes back with the error, The pattern field should contain at least one of the following characters, #, A, * and ?

 

I'm not sure if WebCRD works with FusionPro's HTML Form Feature. But an explanation of the Data Patterns can be found in FusionPro's User Guide. Suggest taking a look at the chapter HTML Form Feature.

 

So I don't know how to lock it to use the data pattern to limit the characters. Can it be set to accept 12 total characters being numbers and periods, or just limit to 10 total numbers? And then apply the correct phone format rule in the text editor?

 

Yes. (Although not entirely sure about FP v7.x.) Digits, alpha characters or a combination of both. In version 10.x you can also use Regular Expressions (RegEx). Explained in the User Guide. Search for Data Pattern Restrictions & Separators. Just not sure if it will work with WebCRD though.

Edited by David Miller
Link to comment
Share on other sites

Ah okay now it makes sense. I was entering numbers instead of the number symbol "#". So yes that works the way I need it to but, as you suspected, once I upload the template, the data pattern is no longer honored. I will see if RSA support has an answer for this.
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...