logo
down
shadow

How do I validate day and month?


How do I validate day and month?

By : user2953591
Date : November 21 2020, 01:01 AM
will be helpful for those in need I have both drop down lists for day and month but textbox for year. please go easy on me I'm a total noob in html, php or css. How do I check if its a valid date? e.g (No 31 April, Leap years) EDIT: This is for input of date of birth. I would like to check if their date of birth input is valid or not. , you can not validate but you can generate data and year
try this
code :
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script>
         $(function() {
         $("#datepicker").datepicker();
         });
 </script>


  <p>Date: <input type="text" id="datepicker" /></p>
          <select name="month" onChange="changeDate(this.options[selectedIndex].value);">
<option value="na">Month</option>
<option value="1">January</option>
<option value="2">February</option>
<option value="3">March</option>
<option value="4">April</option>
<option value="5">May</option>
<option value="6">June</option>
<option value="7">July</option>
<option value="8">August</option>
<option value="9">September</option>
<option value="10">October</option>
<option value="11">November</option>
<option value="12">December</option>
</select>
<select name="day" id="day">
<option value="na">Day</option>
</select>

<script language="JavaScript" type="text/javascript">
function changeDate(i){
var e = document.getElementById('day');
while(e.length>0)
e.remove(e.length-1);
var j=-1;
if(i=="na")
k=0;
else if(i==2)
k=28;
else if(i==4||i==6||i==9||i==11)
k=30;
else
k=31;
while(j++<k){
var s=document.createElement('option');
var e=document.getElementById('day');
if(j==0){
s.text="Day";
s.value="na";
try{
e.add(s,null);}
catch(ex){
e.add(s);}}
else{
s.text=j;
s.value=j;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}}}
y = 1993;
while (y-->1940){
var s = document.createElement('option');
var e = document.getElementById('year');
s.text=y;
s.value=y;
try{
e.add(s,null);}
catch(ex){
e.add(s);}}
</script>


Share : facebook icon twitter icon
Regex to validate day and Month of a given day in PHP

Regex to validate day and Month of a given day in PHP


By : Rebecca C
Date : March 29 2020, 07:55 AM
I hope this helps you . I am trying to write a regex expressions in PHP to validate two variables: , You would be better off using simple php opperators,e.g.
code :
if( $months > 0 && $months < 32 )
Validate input for month

Validate input for month


By : jgfenix
Date : March 29 2020, 07:55 AM
it helps some times This is a regex solution, you just need to test if your string matches this regex:
Regex:
code :
[0-9]{2}[\.:][0-9]{2} [A-Z][a-z]{4,7} ([0-2][0-9]|[3][01])\/(0[1-9]|1[12])
var str = "19.30 Friday 2/10";
var regex= /[0-9]{2}[\.:][0-9]{2} [A-Z][a-z]{4,7} [0-9]\/[0-9]{2}/
if (str.match(regex)) {
  alert("String matched .");
} else {
  alert("String unmatched !!");
}
[0-9]{2}[\.:][0-9]{2} [A-Z][a-z]{4,7} [0-9]\/[0-9]{2}
How to validate days of month using jQuery Validate?

How to validate days of month using jQuery Validate?


By : Samuel Bonnett
Date : March 29 2020, 07:55 AM
To fix the issue you can do After a long research i was been able to achieve the functionality, below is my code
code :
BirthDay: {
required: {
depends: function (element) {
    return $('#TypeID').val() == '11' || $('#TypeID').val() == '12'
}
},
number: true,
range: [1, 31],
validateDate: true
},
BirthDayMonth: {
required: {
depends: function (element) {
    return $('#TypeID').val() == '11' || $('#TypeID').val() == '12'
}
},
number: true,
range: [1, 12]
},
jQuery.validator.addMethod("validateDate", function (value, element) {
if ($('#BirthDayMonth').val() != '') {
    var month = $('#BirthDayMonth').val();
    var day = $('#BirthDay').val();
    var result = false;
    if (month % 2 != 0) {
     result = day <= 31;
    } else {
    if (month == 2) {
    result = day <= 29
    } else {
    result = day <= 30;
    }
    }
    return result;
} else
{
    return true;
}
}, "Entered date doesnot exist in the month.");
Validate Month input 01 and 1?

Validate Month input 01 and 1?


By : Pj Williamson
Date : March 29 2020, 07:55 AM
hop of those help? I need an int value for both inputs. Either the user write 1 or 01 for January. , You get your own error because you don't use the right input :
code :
monthNumber = inputText();
int number = Integer.parseInt(monatZahl);
//-----------------------------^^-----------this should be monthNumber
int number = Integer.parseInt(monthNumber);

if (number < 1 || number > 12) {
    again = true;
    throw new Exception();
}
int i1 = Integer.parseInt("01");
int i2 = Integer.parseInt("1");
How do I display the Month, Month + 1, Month +2, Month +3, Month +4 in a separate column depending on the date?

How do I display the Month, Month + 1, Month +2, Month +3, Month +4 in a separate column depending on the date?


By : Ouissam Gouni
Date : March 29 2020, 07:55 AM
will be helpful for those in need You could use CROSS APPLY to calculate the 5 dates in your final SELECT statement and calculate the month-year-strings using DATENAME:
code :
SELECT hotel_id, snapdate, month, year,
  DATENAME(MM, snapdateex) + N' ' + DATENAME(YYYY, snapdateex) AS Month_TY
FROM @snaps
CROSS APPLY (VALUES
    (snapdate),
    (DATEADD(month, 1, snapdate)),
    (DATEADD(month, 2, snapdate)),
    (DATEADD(month, 3, snapdate)),
    (DATEADD(month, 4, snapdate))) AS hlp(snapdateex)
Related Posts Related Posts :
  • Php how to check multiple times (within `foreach`) if values from array exists in mysql?
  • MySQL and PHP parsing strange string
  • Pull specific data from multidimensional associative array
  • How to get the original URI extension using PHP Tonic?
  • Upload videos and images from Android to PHP server?
  • Unset a multidimensional array with another multidimensional array with values than key
  • Calling a user e-mail to add to a mailto link PHP
  • Why is override_function coming back as an undefined function
  • PHP mySQLi_fetch_all: iterate through each row
  • Using pow in php
  • What's wrong with my PHP Script? T_String issue
  • how to call a function of another file without including that file
  • is_rgb function in php
  • transform the numbers to letters using php
  • How to catch an exception from another class method PHP
  • PHP exec is blocked by ISP
  • PHP4 to PHP5 migration character encoding. latin1 vs utf8
  • Begin Transaction not defined
  • How much harm can a user do with xss on a page unique to them?
  • How to import data from a php file to javascript variable
  • PHP and Javascript - log complete workflow
  • When I echo !!! 0 it gives me a strange result
  • jquery ajax post dies after submit
  • How to upload file with curl on sftp server
  • Advanced search using a text input to search through only one category
  • Why do I get "Non-static method App\Models\Category::products() should not be called statically" in laravel
  • Stop notices from undefined indexes in arrays
  • PHP Excel Error when entering SUM function to a cell
  • laravel 4 eloquent eager load relation count
  • click submit in html and run php code
  • Extremely frustrating behavior with Internet Explorer, Bootstrap and Respond.js
  • Vkontakte vtag issues
  • Divide the number to a correct decimal
  • mysqli_insert_query not working
  • How to make a sitemap using zend framework 1
  • Laravel: array to Model with relationship tree
  • $_SERVER['DOCUMENT_ROOT'] vs $path = $_SERVER['DOCUMENT_ROOT']
  • What is the best way to store multiple checkbox values in the database and work with it later on
  • Why does foreach copy the array when we did not modify it in the loop?
  • Receive Jquery/Ajax Post Request in PHP
  • How to better use the if(!empty()){ //codes} statement
  • PHP error mysql_close() boolean given
  • Move an image file from one server to another using PHP
  • PHP: Encoding non ISO-8859-1 charactrers into utf8
  • Handling MySQL errors in PHP
  • Object orientated mysql num_rows query in one line
  • Remove not closed html elements from end of text
  • Generate random ENUM value [PHP, MySQL]
  • Deleting data from table using jQuery and SQL
  • How to make sure the constructor is executed when I'm trying to reach a static property?
  • Trying to understand arrow next to PHP function
  • Form using external php file to show "Sucess"
  • WooCommerce - new shipping method - how to query individual product weights
  • Common integer representation over variable casting?
  • PHP - Prevent client from tampering the ID of a form
  • unexpected T_PUBLIC error
  • Types of testcases in PHPUnit
  • keeping a LDAP user logged in with PHP session
  • Detect if browser supports WebP format? (server side)
  • real_escape_string not cleaning up entered text
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org