Can the border on a Textbox be removed?

  • 9 March 2015
  • 9 replies
  • 10 views

Badge +4

I have inherited a Smartform and the new requirement is to remove the border on a textbox that we are using as read only data, just to help distinguish it.

I'm not able to locate how to do this.  Under custom styles it already doesn't have a border selected. It appears to be a default property of a textbox. 

It looks like if it was just a data label it wouldn't have a border, but that will take a lot of work changing over to Data Labels from TextBoxes.

Any ideas?


9 replies

Badge +10

So first of all you can "sort of" do this from designer.  Set it to match the background color of the form, or set it to 0px size.  Click the text box control, and the elipsis (...) after style.

 

10756iD9DFAF40065BC930.png

 

 

 

Now, if that solution won't work for you because reasons, or you need to do some other strange conditional formatting, there is another way. The really funny thing here is that a data label is going to be the solution.

So here's the test form...  Text box and a label.

 

11038i2D66B874F5FEB0EE.png

 

Now, I did some digging, and figured out the <div> element we need using firebug/chrome dev tools/IE F12

16049i28C3FAA53C87E08F.png

 

See that border property over on the CSS side of things?  Yeah, that's what we need to change.  We also see the input's name as "Text Box" (which is pulled from designer).

 

So.... 

$( "input[name='Text Box']").css( "border","none"); 

 Will go ahead and remove that border for you.

 

So now, lets go back to that data label.  Data labels parse HTML, which is great.  So that becomes:

 

<script> $( "input[name='Text Box']").css( "border","none");  </script>

 

Looks like under the 255 character limit to me.

 12934i2D664C266D7E1EF5.png

12205i3983AAA30B577CAD.png

 

So now, once the form loads, the value of our data label is set to that value, and our border disappears.  I believe somewhere on the community site there's an HTML literal control that allows more than 255 characters to be placed in it just in case more room is needed.

The reason a transfer data rule is used, is because setting the value on the view itself will remove every text box border on your designer site, as the HTML/Jquery is rendered imediatley on the design time site, and would grab anything with a matching name.  It also becomes very very difficult to find a label to delete/modify/remove it once it's value has been set with HTML or javascript.

 

Hopefully that helps.

 

 

Badge +10

I dont think you need to do all that. Just do to the properties of the textbox and click the styles. Then go to the border tab and then select transparent. then set the border pixel to 0 and then apply the borders. htis will remove all borders.

 

Hope that helps.

Badge +4

Thanks for the replies!

SmartForms ignore any formatting I try to do on the border for a control TextBox. 

I have:

1. Set the border 0px and set the color to 'no color' - the border still shows

2. I have created a rule and used the code <script> $( "input[name='TextBox_FirstName']").css( "border","none");  </script>, but as this was written for DataLabels and not TextBoxes, it doesn't work, just displays the literal text

 

Did I do something wrong?  Or did I not understand some of the instructions?

 

DataLabels will by default display without a border - it sounds like I need to switch all these over to DataLabels from TextBoxes if I want to meet this requirement.  Not sure I want to take on that risk.

 

Badge +10

Jamie,

 

Essentially, you want to create a rule that transfers that script to a seperate data label on the form, and not to the textbox itself.  Post a screenshot of your rule configuration and I can assist.

 

When the page is rendered, the data label containing the HTML tags will be loaded as part of the page itself, and execute.  I don't believe setting a value on a text box will have the same result.

 

Regards,


Mike

Badge +4

Ah- I didn't follow direction correctly! 

Still doing something wrong:

1. Name of TexBox I'm trying to hide - TextBox_FirstName

2. I created a hidden DataLabel - HdnDataLbl_FN

3. Created a rule - screen shots below

 

Thanks for your help!

 

12540i3D7FA3223C64B531.gif

 

12032iBD26102E25F2411F.gif

 

 

 

Badge +4

Wait!  I did get it to work.  In my haste of creating the hidden field I unchecked literal - it has to have that!

It works now.

 

Now to add all the TextBoxes I don't want borders on.

Thanks!!

Badge +10

Glad I could be of help!  You can do quite a bit more with that than just remove textboxes, in case you need to do some weird stuff with CSS.  I used something similar to set the background color of a specific view on a form conditionally, which, unfortunately at this time isn't possible out of the box.  It's messy, but if you're trying to do something "strange", its another tool that can be used.

Badge +4

I think the next thing I'll be asked to do that I'm not clear on is how to put nice boxes around Form controls.  I have a mixture of views that have nice borders, and a couple of controls that are just on the form hanging out (Like the screen shot below).  Trying to figure out how to give them nice boxes.

 

16347iA4494C8C9F28130C.gif

Badge +10

Hi Jamie,

 

You certainly can use a similar method to do this, but I'd hesitate to be making change after change using this method, as it can sort of create a mess for anyone inheriting the form who needs to make changes.  It's almost at the point where I'd suggest a custom theme to do this.  For a one off change on a form, this method works, but I think you'd have more success with a custom theme, especially if these requirements will be reused on other forms.  All our jQuery is doing in our previous case is modifying the CSS of the page "on the fly".

Documentation can be found here: http://help.k2.com/onlinehelp/K2smartforms/DevRef/current/default.htm#Creating_a_Custom_Theme.html on that subject.  Essentially, you're editing the CSS directly, and it'll make things a bunch cleaner.  Assuming you're slightly familiar with HTML and CSS (or visit codeacadamy/stackoverflow/w3schools frequently) , custom themes are actually pretty easy to create.


Regards,

 

Mike

Reply