Use Fieldset Legend with bootstrap

That’s because Bootstrap by default sets the width of the legend element to 100%. You can fix this by changing your legend.scheduler-border to also use: legend.scheduler-border { width:inherit; /* Or auto */ padding:0 10px; /* To give a bit of padding on the left and right */ border-bottom:none; } JSFiddle example. You’ll also need to … Read more

Check if option is selected with jQuery, if not select a default

While I’m not sure about exactly what you want to accomplish, this bit of code worked for me. <select id=”mySelect” multiple=”multiple”> <option value=”1″>First</option> <option value=”2″>Second</option> <option value=”3″>Third</option> <option value=”4″>Fourth</option> </select> <script type=”text/javascript”> $(document).ready(function() { if (!$(“#mySelect option:selected”).length) { $(“#mySelect option[value=”3″]”).attr(‘selected’, ‘selected’); } }); </script>

Using JQuery – preventing form from submitting

Two things stand out: It possible that your form name is not form. Rather refer to the tag by dropping the #. Also the e.preventDefault is the correct JQuery syntax, e.g. //option A $(“form”).submit(function(e){ e.preventDefault(); }); Option C should also work. I am not familiar with option B A complete example: <html> <head> <script type=”text/javascript” … Read more

Using the HTML5 “required” attribute for a group of checkboxes?

Unfortunately HTML5 does not provide an out-of-the-box way to do that. However, using jQuery, you can easily control if a checkbox group has at least one checked element. Consider the following DOM snippet: <div class=”checkbox-group required”> <input type=”checkbox” name=”checkbox_name[]”> <input type=”checkbox” name=”checkbox_name[]”> <input type=”checkbox” name=”checkbox_name[]”> <input type=”checkbox” name=”checkbox_name[]”> </div> You can use this expression: $(‘div.checkbox-group.required … Read more

How to prevent form resubmission when page is refreshed (F5 / CTRL+R)

I would also like to point out that you can use a javascript approach, window.history.replaceState to prevent a resubmit on refresh and back button. <script> if ( window.history.replaceState ) { window.history.replaceState( null, null, window.location.href ); } </script> Proof of concept here: https://dtbaker.net/files/prevent-post-resubmit.php (Link no longer works) I would still recommend a Post/Redirect/Get approach, but this … Read more

Using PUT method in HTML form

According to the HTML standard, you can not. The only valid values for the method attribute are get and post, corresponding to the GET and POST HTTP methods. <form method=”put”> is invalid HTML and will be treated like <form>, i.e. send a GET request. Instead, many frameworks simply use a POST parameter to tunnel the … Read more

JavaScript Form Submit – Confirm or Cancel Submission Dialog Box

A simple inline JavaScript confirm would suffice: <form onsubmit=”return confirm(‘Do you really want to submit the form?’);”> No need for an external function unless you are doing validation, which you can do something like this: <script> function validate(form) { // validation code here … if(!valid) { alert(‘Please correct the errors in the form!’); return false; … Read more

How to add ID property to Html.BeginForm() in asp.net mvc?

This should get the id added. ASP.NET MVC 5 and lower: <% using (Html.BeginForm(null, null, FormMethod.Post, new { id = “signupform” })) { } %> ASP.NET Core: You can use tag helpers in forms to avoid the odd syntax for setting the id. <form asp-controller=”Account” asp-action=”Register” method=”post” id=”signupform” role=”form”></form>

jquery disable form submit on enter

If keyCode is not caught, catch which: $(‘#formid’).on(‘keyup keypress’, function(e) { var keyCode = e.keyCode || e.which; if (keyCode === 13) { e.preventDefault(); return false; } }); EDIT: missed it, it’s better to use keyup instead of keypress EDIT 2: As in some newer versions of Firefox the form submission is not prevented, it’s safer … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)