I have follwing css class
form input[type="text"], form input[type="email"], form input[type="password"], form select, form textarea {
border: 1px solid #CCCCCC;
border-radius: 3px 3px 3px 3px;
padding: 2px 0;
}
and following html and Java Script:
<input type="text" id="txt1" style="width:300px;" />
<input type="button" id="btn" value="click here" class="medium required" onclick="return validate();"/>
<script language="javascript">
function validate()
{
if (document.getElementById('txt1').value == '') {
document.getElementById('txt1').style.borderLeft = "5px solid red";
return false;
}
}
</script>
It works in Mozila but in google Chrome whenever validation fires inputbox gets css exctly applied in javascript but it also creates top and bottom border of 1px solid
you can check this example on : http://jsfiddle.net/unloco/VFBT3/3/
how can i solve this issue? Thanks.
Seems to be a bug with border-radius: 3px 3px 3px 3px; and -webkit-border-radius: 3px 3px 3px 3px; If you remove that from the CSS, then there is no issue with Chrome
cf - http://jsfiddle.net/VFBT3/20/
Yeah it seems you have caught some bug.But you can also do this thing like this:
http://jsfiddle.net/VFBT3/46/
CSS
form input[type="text"], form input[type="email"], form input[type="password"], form select, form textarea {border: none;height: 20px;vertical-align: top;}
div{width: 305px;height: 20px;border: 1px solid #CCC;
border-radius: 3px;}
*{margin:0;padding:0;}
HTML:
<form style="margin: 20px;">
<div>
<input type="text" id="txt1" style="width:300px;" />
</div>
<input type="button" id="btn" value="click here" class="medium required" onclick="return validate();"/>
</form>
JS will be same.
Related
Morning All
Although I am able to change the BorderColor of a <asp:Textbox> through CSS, I am currently wondering why such attempt fails once a user clicks on the Textbox (e.g. a default BorderColor persists).
<style type="text/css">
.txt{
border: 1px solid;
border-color:#cfd1d4;
}
.txt:hover{
border: 1px solid;
border-color: #cfd1d4;
}
.txt:focus{
border: 1px solid;
border-color: #cfd1d4;
}
</style>
...
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox id="_txt_did" placeholder="this is a test case" runat ="server"
Width="90%" Font-Size="14px" Font-Italic="true" CssClass ="txt"></asp:TextBox>
</div>
</form>
</body>
...
P.S. I've added a picture for an illustration of the issue. The purpose was to keep identical Textbox(es) (benchmark being the one PageLoad()) even if one clicks on the Textbox
You have the same border-color in all of your styles just change it and try
<style type="text/css">
.txt{
border: 1px solid;
border-color:#681807;
}
.txt:hover{
border: 1px solid;
border-color: #07685F;
}
.txt:focus{
border: 1px solid;
border-color: #68075E;
}
</style>
<html>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox id="_txt_did" placeholder="this is a test case" runat ="server"
Width="90%" Font-Size="14px" Font-Italic="true" CssClass ="txt"></asp:TextBox>
</div>
</form>
</body>
</html>
I know this type of question has been asked before, but I couldn't get the answer. I have a contact form, and I want to implement the new Invisible Google Recaptcha. However, I have used an <input> rather than a <button> and I can't figure out how to do this. Here is my code for the contact form I have:
input, textarea {
padding: 5px;
margin: 10px;
font-family: Cambria, Cochin, serif;
font-size: medium;
font-weight: bold;
outline: none;
}
input[type=text], textarea {
width: 350px;
background-color: #b6b6b4;
border: 1px solid #989898;
border-radius: 10px;
}
input[type=submit] {
width: 100px;
background-color: #989898;
border: 1px solid #707070;
font-size: large;
color: #000;
border-radius: 5px;
}
input[type=submit]:hover {
background-color: #848484;
cursor: pointer;
}
input[type=submit]:active {
background-color: #989898;
}
<script src="https://www.google.com/recaptcha/api.js"></script>
<!--CONTACT FORM-->
<form name="contactform" method="post" action="send_form_email.php">
<div>
<input name="name" type="text" placeholder="Name..." required> <br> </div>
<div>
<input name="email" type="text" placeholder="Email..." required>
<br>
</div>
<input type="checkbox" name="maillist" value="1" checked> Subscribe to mailing list<br>
<div>
<input name="game" type="text" placeholder="Game suggestions...">
<br>
</div>
<div>
<textarea cols="30" name="comment" rows="9" placeholder="Comments..."></textarea>
<br> </div>
<div>
<input name="submit" type="submit" value="Submit"> </div>
</form>
Then I have the google ReCaptcha button:
<button
class="g-recaptcha"
data-sitekey="############################"
data-callback="YourOnSubmitFn">
Submit
</button>
Any Help would be appreciated. Also, I was wondering if you could remove the ReCaptcha logo on the bottom right.
try this, It will hide the Google reCaptcha Invisible Badge over the page.
.grecaptcha-badge {
display: none !important;
}
Keep in mind the badge should be displayed as Google pretends the "privacy" and "terms" links to be present.
From the reCaptcha docs check this g-recaptcha tag attributes and grecaptcha.render parameters section:
g-recaptcha tag attribute: data-badge
grecaptcha.render parameter: badge
Value: bottomright
bottomleft
inline
Default: bottomright
Description: Optional. Reposition the reCAPTCHA badge. 'inline' allows you to control the CSS.
This is a basic example
<html>
<head>
<title>reCaptcha example</title>
<script src='https://www.google.com/recaptcha/api.js'></script>
<style>
.grecaptcha-badge {
display: none;
}
</style>
</head>
<body>
<form id="demo-form" action="/post" method="post">
<button data-sitekey="your_site_key" data-callback='onSubmit' data-badge="inline">Login</button>
</form>
</body>
</html>
Set the data-badge attribute to inline, notice the data-badge="inline":
<button type="submit" data-sitekey="your_site_key" data-callback='onSubmit' data-badge="inline">Login</button>
And on the html code:
<style>
.grecaptcha-badge {
display: none;
}
</style>
You could also just add to your CSS:
.grecaptcha-badge {
display: none;
}
How to cancel the blur effect of the HTML textbox when focus on it?
<input type='text' style="background-color:#33ccff; color:#AD8C08; border:1px solid #ffffff; "></input>
You have to use CSS on the input element on focus to eliminate that "blur" effect that you're talking about. Take a look at this JSFiddle for an example.
http://jsfiddle.net/qfr8eng1/1/
HTML:
<input type="text" id="noeffect" value="look at me!"/>
CSS:
#noeffect
{
background-color: #33ccff;
color: #AD8C08;
border: 1px solid #ffffff;
}
#noeffect:focus
{
outline: none;
}
try it......
.onfocus { background-color:#33ccff; color:#AD8C08; border:1px solid #ffffff; }
.onfocus:focus { background:none; }
<input type='text' class="onfocus"></input>
Very quick and basic question but one I can't seem to find the answer to online.
In CSS, is it possible to style a "submit" based purely on the form it is in? Furthermore is there any reason to not do this, and instead to use an specific name like #subit_search_form
Of course it is. Lets say your form has an id of MyForm, your CSS would look like this:
#MyForm button
{
}
Here is a working example
this will style all button elements with the form with id MyForm.
depends on what hooks you have to style...
give the form an id and then...
<form id="certain-form" >
...
<button type="submit">Your Button</button>
</form>
The css:
#certain-form button { ..your unique styles.. }
Yes it is Possible.
Here is the Solution.
The HTML:
<form>
<label>
<input type="button" value="Button" class="button"></input>
</label>
</form>
OR
<form>
<label>
<input type="submit" value="Button" class="button"></input>
</label>
</form>
The CSS:
.button
{
border-top: 2px solid #a3ceda;
border-left: 2px solid #a3ceda;
border-right: 2px solid #4f6267;
border-bottom: 2px solid #4f6267;
padding: 10px 20px !important;
font-size: 14px !important;
background-color: #c4f1fe;
font-weight: bold;
color: #2d525d;
}
Hope this Helps.
EDIT
If you want to target using specific attribute. Here is the Solution.
The CSS Change
input[type="submit"]
{
border-top: 2px solid #a3ceda;
border-left: 2px solid #a3ceda;
border-right: 2px solid #4f6267;
border-bottom: 2px solid #4f6267;
padding: 10px 20px !important;
font-size: 14px !important;
background-color: #c4f1fe;
font-weight: bold;
color: #2d525d;
}
Alternatively this also can be used.
I just want to share, although your problem have been resolved..
If you want to add style to submit instead to use specific name of form like #subit_search_form, You could use jquery selector form with name and input with type to add css style.
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$("form[name=subit_search_form] input[type=submit]").css({
"background-color": "#FE9900",
"font-weight": "bold",
"font-family": "Arial,Helvetica,sans-serif",
"border": "1px solid #000066",
"cursor": "pointer"
});
</script>
<form name="subit_search_form">
<input type="submit" name="submit" id="submit" value="Search" />
</form>
jsffile
But I prefer with solution from #musefan, using button
I tried making a custom submit button for my simple contact form because I wanted to style it a bit with CSS. I set the input type to submit and whenever I click the button it neither submits nor is click able.
I created a class called blue button, and my style will show but cannot submit.
<a class="blue button" input type="submit">Everything? Send!</a>
I then tried this method instead and it submits, but it does not show my style that created!
<input class="blue button" type="submit" value="Send">
Form
<form method="post" id="submitform" action="submitemail.php" >
<input type="text"
class="formstyle"
title="Name"
data-placeholder="Name..."
name="name" />
<input type="text"
class="formstyle"
title="Email"
data-placeholder="Website..."
name="website" />
<input type="text"
class="formstyle"
title="Email"
data-placeholder="Email..."
name="email" />
<input type="text"
class="formstyle"
title="Email"
data-placeholder="Business or Personal?"
name="type" />
<textarea name="message"
data-placeholder="Message..."
title="Message"></textarea>
Is there anyway to have a submit button from element styled button like below?
<a class="blue button" input type="submit">Everything? Send!</a>
CSS as requested:
.button.blue {
border: 1px solid #005998;
}
.button.blue .text {
padding: 16px 31px 14px;
text-transform: none;
text-shadow: 0 -1px 0 #022268;
}
.button.blue .normal {
background: linear-gradient(#00a7f7, #0563bb);
background: -webkit-linear-gradient(#00a7f7, #0563bb);
background: -moz-linear-gradient(#00a7f7, #0563bb);
background: -o-linear-gradient(#00a7f7, #0563bb);
background: -ms-linear-gradient(#00a7f7, #0563bb);
-pie-background: linear-gradient(#00a7f7, #0563bb);
box-shadow: 0 1px 0 #12dbff inset;
-webkit-box-shadow: 0 1px 0 #12dbff inset;
-moz-box-shadow: 0 1px 0 #12dbff inset;
-ms-box-shadow: 0 1px 0 #12dbff inset;
-o-box-shadow: 0 1px 0 #12dbff inset;
behavior: url(pie.htc);
}
.button.blue .hover {
display: none;
background: linear-gradient(#008af3, #0244a2);
background: -webkit-linear-gradient(#008af3, #0244a2);
background: -moz-linear-gradient(#008af3, #0244a2);
background: -o-linear-gradient(#008af3, #0244a2);
background: -ms-linear-gradient(#008af3, #0244a2);
-pie-background: linear-gradient(#008af3, #0244a2);
box-shadow: 0 1px 0 #12c4ff inset;
-webkit-box-shadow: 0 1px 0 #12c4ff inset;
-moz-box-shadow: 0 1px 0 #12c4ff inset;
-ms-box-shadow: 0 1px 0 #12c4ff inset;
-o-box-shadow: 0 1px 0 #12c4ff inset;
behavior: url(pie.htc);
}
<a class="blue button" input type="submit">Everything? Send!</a>
This is totaly wrong. For form submit button:
<input type="submit" class="blue-button" value="submit" />
I dont know if you really understand the concept of css, either way here is what you can try:
1 - remove the .normal from the rules, its not used.
2 - put the input submit inside the form.
3 - order the class on css, like .blue.button not button.blue(jsut to organize)
4 - the .hover is a class or the effect? if its the effect the correct is :hover
try these
You may try something like;
<a class="blue_button" input type="submit"><input class="submit_button" type="submit" value="Send"></a>
and you may give submit_button a styling of display: block; width: 100%; height: 100px; margin: none; border: none;. I recommend giving it a width and height in px (fixed width). This is not tested.
Leaving space in defining class names to elements will treat them as multiple classes. For example, if you use class="blue button", it says that the element may get styling defined on .blue and .button.