sent an email text-area content white-space style not working - whitespace

I have an email with a text-area input field and one value contains a string with multiple lines. (enter-key) When viewed in my local email template, the white-space (pre-wrap) is not working.
Any one have idea to how to fix it?

Related

Node wont save if text field contains word "having"

When I try to save edited node Drupal just reset field values and do nothing without any error message or log.
I entered text word by word and found that word "having" cause such behavior.
I'm using ckeditor to edit and filter text value and I guess that this module source of problem. As if I save text as plain text there are no issues.
Right now I don't know what to do next to track, dig deeper and isolate this issue...
PS. In ckeditor format settings I checked only two options:
Limit allowed HTML tags and correct faulty HTML
Convert line breaks into HTML (i.e. br and p)

How to Validate a textfield in AEM/CQ so that no numbers are entered?

I have a requirement where in a textfield only alphabets from a-z or A-z be entered and nothing more. I am wondering how to do it. Are there any properties available. I couldn't find one. Can we use allowNumbers: false (its not working. I tried may properties but all in vain)
You can use the property regex to specify a regular expression against which the value of the field would be tested.
For e.g., the following configuration would allow only alphabets and white spaces in the textfield. You can also use the regexText property to specify a custom error message when the validation fails.
<title jcr:primaryType="cq:Widget"
fieldLabel="Text"
name="./text"
regex="/^[A-Za-z ]+$/"
regexText="Kindly verify the field. Only characters are allowed."
xtype="textfield"/>
For more information, refer the Widget API

How can I stop Joomla from stripping HTML code from the Contact info?

I've only spent maybe 30 mins searching online for this, and couldn't come up with a decent answer.
But anyway, in Joomla there are normal input fields for the Contacts component, but there's a textarea for the Address.
This would make me assume you can enter multiple lines of address in there, and it would be displayed as separate lines... but it doesn't. Even if I enter line breaks, the output is rendered on one line.
So I try to enter <br> to separate, and upon saving, Joomla strips these tags out.
In the template, the output is being written simply by echoing $this->contact->address
Is there anyway, to explode this input and replace linebreaks with <br> marks?
UPDATE:
For now as a temporary measure I'm able to add HTML code into the database values, which saves and outputs on the front end.
On a separate note, I'm now looking to remove the Subject line from the contact form, without hacking the code. and by using overrides as much as possible. Can anyone help?
Have you tried the Sourcerer extension?
Your question is pretty old, but did you get a solution to this Lee?
To create line-breaks in Joomla, titles, text areas etc. Easiest way to do this is to use the ReReplace extension from NoNumber: http://extensions.joomla.org/extensions/edition/replace/4336
I personally use this to add line break in e.x. menu-item titles, where < br / > aren't allowed and get stripped.
With ReReplacer, you can create a custom tag e.x. {br} and then have ReReplacer replace {br} with < br / >.
So everytime you need to add a line break anywhere in Joomla, where html codes usually get stripped, you can just add {br} to have it add a new line.
Very old question but I've fallen into the same issue and tried to find a more user friendly solution.
You can enter multiple lines in the address textarea, and they are correctly outputted to the HTML page source. But as you know, newlines in HTML are not rendered, they have to be transformed to <br>.
For this PHP has a nice function, nl2br, that inserts a <br> each time it encounters a newline in a string.
So in html\com_contact\contact\default_address.php of your template, replace:
echo $this->contact->address;
with
echo nl2br($this->contact->address);
This would nicely do the job, and allow the user to naturally insert any newline in the contact address textarea that will be correctly rendered with the appropriate <br>; I believe this is quite more user friendly solution than your previous one of the user having to insert -br- tags in the address field.

Knockout set initial value of an input field where html is allowed

I have two input fields first name and last name.
Application was running really well.
Suddenly someone came in from Mars and input something like this in those input fields
*(~'##~>?<+!""*%$)!
for both first name and last name. Now don't ask me why he did this cause in Mars this is very common. You can try it on this fiddle
http://jsfiddle.net/farrukhsubhani/3RjRF/
This text then went into my database and now when i retrieve it it came back like this
*(~'##~>?<+!""*%$)
which is ok for me as its html and I can place it back into knockout and it gets populated as html as you can see in fiddle above. However this Mars guy then thought that on Earth this is not a nice name to be with so he tried to edit field.
The above fiddle is kind of that edit page which shows him old value at bottom and two fields at top. He does not know html so he thought we have changed his name in input fields however I need to know
When passing text to knockout to give initial value to an input field is it possible to tell it that consider this text as html so it renders properly in input field
The other way around is to send him to http://www.w3schools.com/tags/ref_entities.asp and tell him about reserved HTML characters. This info has been stored in database (using Entity Framework simple person.fname and person.lname both with attribute AllowHTML) so on my fiddle i have just placed it in two variables and you can see how actual text boxes are different than html below. If i dont bind using Knockout then actual text is shown in these boxes and user can edit <>' signs without any problem.
Anyone with a solution before he leaves our planet. This can change alien life on our planet.
Update
If i go into this field and paste (~'##~>?<+!""*%$)" binding works fine and you can copy this and paste it into fiddle to see that. However its not taking that value from Javascript variable to knockout expects it to be a string and html special characters are not shown properly in input field.
We have done another test without Knockout and this text does get rendered within the field when you try to edit it its fine.
We have updated JSfiddle to work without JQuery and its the same result if you store it in a js variable and give not value to input field
http://jsfiddle.net/farrukhsubhani/3RjRF/3/
If we assign value to input field and just use jQuery to populate fullname then it works
http://jsfiddle.net/farrukhsubhani/3RjRF/4/
This last fiddle is a working example and we want Knockout to do what JQuery is doing.
I think the question then comes to how can this text be stored in javascript variable and placed into input field as html text so special characters appear unescaped. You can try unescape on jsfiddle that did not work for us.
Somewhere along the trip into (or maybe out of) your database, the value is being HTML-escaped. It's not Knockout itself that's doing it. You're going to need to track that location down, but you can't just disable it; you're going to have to replace it with something that sanitizes the result or otherwise you're opening yourself up to cross-site scripting attacks (any <script>s from external sources inserted into the input would have complete access to your data).
Any time you see the html: binding used, warning bells should go off in your head and you should VERY carefully to check to ensure that there's NO possibility of raw, unexamined user input making it into the string that gets displayed.
Ok here is what i did at the end
http://jsfiddle.net/farrukhsubhani/3RjRF/7/
I have done following:
I have added value attribute to input field and placed the input text as it came from server into it. Because I am using TextBoxFor in MVC it did that for me.
Before I apply knockout binding I have picked this value up using $('#kfname') and passed it to the actual binding so it used the value that came from server. Previously it was passed like (#Model.fname,#Model.lname)
I think what this did was allowed jQuery to pick up the value and assign it to binding instead of variable
ko.applyBindings(new ViewModel($("#kfname").val(), $("#klname").val()));
Hopefully this would help someone using knockout.

ALT+ENTER, how to detect the newline in NSString?

in my Cocoa App I have a textfield, where users are supposed to insert a newline by pressing ALT+ENTER. That's fine... when I get the value of it as a NSString and do a NSLog, I actually see that new lines are print.
But when I append the string as part of an html page with appendString and then with loadHTMLString, the new lines are completely ignored in the resulting web page...
Could you kindly give me a suggestion or a documentation link to read? I have really no idea!
Thanks a lot!!!
Plain newline characters are not rendered by browsers.
Replace the newline characters ( \n ) by line break tags ( <br> ).
NSString *newString = [oldString stringByReplacingOccurancesOfString:#"\n" withString:#"<br>"]
The <br> tags will show as newline characters in the webpage.
The issue is that the new lines that exist in the string are inserted literally into the html document source. Newlines in html source do not get rendered literally when the html document is rendered. (Imagine if they did; you'd have many, many extra new lines displayed because of all those new line characters separating html tags.)
Instead you should process the raw text entered by the user to produce html source which will render as what the user entered. So you have to break the text up into paragraphs and then insert appropriate <p></p> tags.
You can use the NSString method enumerateSubstringsInRange:options:usingBlock: with the option NSStringEnumerationByParagraphs. To process each paragraph.
Also, you should to sanitize the data entered by the user. For example you don't want your page to get messed up if the user enters some html tags. Sanatizing the data may be as simple as replacing all the restricted characters in the text with the appropriate html entities, but it depends on what you're doing.

Resources