Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I am using a date picker from twitter bootstrap and I want to add some validation that your sign up will not suppose to be registered once your date is below 18 years of age, how am I supposed to do that? here is my sample html code for the birthdate:
<label>Date of Birth*</label>
<input type="date" name="birth_date" tabindex="7" style="height: 30px;" required>
If you look down the demo page a bit, you'll see a "Restricting Datepicker" section. Use the dropdown to specify the "Year dropdown shows last 20 years" demo , and hit view source:
$("#restricting").datepicker({
yearRange: "-20:+0", // this is the option you're looking for
showOn: "both",
buttonImage: "templates/images/calendar.gif",
buttonImageOnly: true
});
You'll want to do the same (obviously changing -20 to -100 or something).
Or you can use
$('#dp1').datepicker({
format: 'mm-dd-yyyy',
startDate: '-15d',
endDate: '+0d' // there's no convenient "right now" notation yet
});
You need to validate the user input either using javascript or the scripting language you're going to use.
An example in PHP would be:
<?php
if(isset($_POST['birth_date']))
{
if($_POST['birth_date'] < 1996)
{
echo 'You can not register';
}
}
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
So, I have this html form which the user fills up with his/her info. There is the mobile number field.
I´d like to add the country code automatically, but hidden from the user (since it´s going to be just a local - geographic - marketing action, it´s a fixed code), so I can receive the mobile number with the country code added directly to the database.
All I need is that the form (or JS) adds the value "11" to the beginning of the mobile number without the user noticing it. The user writes "321-456789" and I will receive "11321456789".
How to code that?
Thanks!
You can use JS to prepend (kudos to Stephen P's amazing vocabulary) "11" to the value of the input field like so:
function append11(){
var mobilenumber = document.getElementById("phonenumber");
var front = document.getElementById("front").value;
mobilenumber.value=front+mobilenumber.value;
}
<input type="number" id="phonenumber"><input type="number" value="11" id="front" hidden><button onclick="append11()">
Append 11
</button>
In the example above, whatever you input, after clicking the 'Append 11' button, will add "11" to the front of the value. You can configure this to submit a form like so:
function append11(){
var mobilenumber = document.getElementById("phonenumber");
var front = document.getElementById("front").value;
mobilenumber.value=front+mobilenumber.value;
alert(mobilevalue.value);
}
<form action="something" method="GET">
<input name="phonenumber" type="number" id="phonenumber"><input type="number" value="11" id="front" hidden><button onclick="append11()">
Submit
</button>
</form>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
I have simple question is that, how to make Datetime picker in Asp.net VB?
Im new in ASP.net need your help
Use input field with type="date"
Plain HTML
<input id="date" type="date">
For ASP.NET control:
<asp:TextBox runat="server" type="date" />
ref for more options https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/date
Using jQuery UI plugin:
You should check out the jQuery UI DatePicker.
ASP.NET Example
<script>
$(function() {
$( "#<%= txtDate.ClientID %>" ).datepicker();
});
</script>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtDate" runat="server" />
</div>
</form>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is there some way to make autocompleting by the first letter for select dropdown list not on jQuery but on PURE JavaScript? Something like [only example !!!]:
<input type="text" onkeyup="autoComplete();" />
<select id="mySelectDropdwonList">
<option>John</option>
<option>Michael</option>
<option>Toml</option>
</select>
<script type="text/javascript">
function autoComplete() {
// what is the code ??
}
</script>
It should work like the jQuery-solution by the link http://harvesthq.github.io/chosen/ but on pure JS
A solution just in HTML5:
<input type="text" list="mySelectDropdwonList" />
<datalist id="mySelectDropdwonList">
<option>John</option>
<option>Michael</option>
<option>Toml</option>
</datalist>
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 8 years ago.
Improve this question
I have the following script.
<script>
$(function() {
var date = $('#date').datepicker({ dateFormat: 'yy-mm-dd' }).val();
});
</script>
It displays the datepicker when selected the text box. But I want the current date as default in the text box.Help me
Assuming that you are using jQuery UI's datepicker, you can use setDate to set the date.
var date = $('#date').datepicker({
dateFormat: 'yy-mm-dd'
}).datepicker('setDate', new Date()).val();
1)using php you can to it easily as:
<input type="text" id="date" name="date" value="<?php echo date('Y-m-d')?>" />
2)by using datepicker you can do it like below:
var date = $('#date').datepicker({
dateFormat: 'yy-mm-dd'
}).datepicker('setDate', new Date()).val();
This question already has answers here:
jQuery UI DatePicker - Change Date Format
(29 answers)
Closed 8 years ago.
I have a simple html form that asks for two dates to select, and on the next page they are used in a MySQL query. Problem is, datepicker uses mm/dd/yyyy as the format, and I need yyyy-mm-dd for MySQL.
Is there a simple way to do this? I don't care if the datepicker's format is changed, or if I have to add a middle step to convert it, but whenever I search for examples they all look way overly complicated and include stuff I'm not even using.
I don't think the code is really important since it's so simple, but here's what I have in the header;
<script>
$(function() {
$( "#datepicker" ).datepicker();
$( "#datepicker2" ).datepicker();
});
</script>
And here's what's in the body;
<form method="post" action="stat_report.php">
<h1>Report Summary</h1>
Format: YYYY-MM-DD<br>
Start Date: <input type="text" name="startDate" id = "datepicker"><br>
End Date: <input type="text" name="endDate" id = "datepicker2"><br>
<input type="submit" value="Submit">
</form>
Like so: $('#someId').datepicker({ dateFormat: 'yy-mm-dd' });
This could solve your Problem: http://api.jqueryui.com/datepicker/#option-dateFormat