Jump to content

Code to ignore <enter> in a Field


davers

Recommended Posts

Hi,

 

Is there a way FusionPro can recognize a hard/soft return in a Field and ignore it?

 

The Field is a multi-line field type. We have formatted the data in the Field to break in 2 lines (after the first "of"), but if the user hits <enter> while typing the info, the data will output an extra break.

 

Example of the correct format is:

Doctor of

Psychology

 

But when the user hits <enter> themselves after the "of" we get an extra line break

 

Doctor of

 

Psychology

 

Thanks for all the help! This Forum has been invaluable!

Link to comment
Share on other sites

The user types in the data on EFI Digital Storefront website

Then you'll need to ask EFI how their web application handles a "soft return" typed by the user into one of its web forms. Ideally, it would turn this into a <br> tag for FusionPro instead of a <p> tag. That's what the Variable Text Editor dialog in FusionPro VDP Creator (Desktop) does when you type Shift+Enter.

Link to comment
Share on other sites

Actually, re-reading the original question, the DSF is presumably already placing either a <br> or <p> tag into the field data. So you could just strip these out with a simple JavaScript rule, like so:

return Field("Your Field Name").replace(/<br>|<p>/gi, " ");

 

Although I think it's probably easier to use a single-line field if you really don't want the user to type embedded newlines.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...