Javascript Fomat日期YYYY-MM-DDTHH:MM:SSZ,js

Javascript Fomat日期YYYY-MM-DDTHH:MM:SSZ,js,javascript,jquery,html,Javascript,Jquery,Html,我需要用javascript验证下一种格式的html中是否引入了day YYYY-MM-DDTHH:MM:SSZ 这是我的Html <div class="row"> <div class="col-sm-8"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-t

我需要用javascript验证下一种格式的html中是否引入了day YYYY-MM-DDTHH:MM:SSZ

这是我的Html

<div class="row">
      <div class="col-sm-8">
        <div class="panel panel-default">
          <div class="panel-heading">
            <h3 class="panel-title">Edit Todo</h3>
          </div>
          <div class="panel-body">
          <div class="input-group input-group-sm">
              <span class="input-group-addon">ID</span> <input type="textbox" class="form-control" id="id_to_edit">
            </div> 
            <div class="input-group input-group-sm">
              <span class="input-group-addon">Date</span> <textarea type="text" class="form-control" placeholder="YYYY-MM-DDTHH:MM:SS" id="date_to_edit"></textarea>
            </div>

            <span id="update_result"></span>

          </div>
        </div>
      </div><!-- /.col-sm-8 -->
      <div class="col-sm-4">
        <button type="button" class="btn btn-info" id="button_edit_todo">Edit Todo</button>
        <div class="input-group input-group-sm">
          <span class="input-group-addon">ID</span>
          <input type="text" class="form-control" id="todo_id_edit">
        </div>
        <button type="button" class="btn btn-info" id="button_save_todo">Save Todo</button>
      </div>
    </div>

编辑待办事项
身份证件
日期
编辑待办事项
身份证件
保存待办事项
这是我的javascript

$("#button_edit_todo").click(function(e){
$("#update_result").text('');
e.preventDefault();
if($('#todo_id_edit').val() == ""){
    $('<div class="alert alert-info"> <strong>Oh!</strong> Debes proporcionar una ID </div>').appendTo($("#update_result"));
}else if (isNaN($('#todo_id_edit').val())){
    $('<div class="alert alert-info"> <strong>Oh!</strong> La ID debe ser un numero </div>').appendTo($("#update_result"));
}else{
    getTodoToEdit($('#todo_id_edit').val());
}
$(“#按钮(编辑)待办事项”)。单击(功能(e){
$(“#更新结果”)。文本(“”);
e、 预防默认值();
如果($('#todo_id_edit').val()=“”){
$('Oh!Debes proportionar una ID')。附录($(“#更新#u结果”);
}else if(isNaN($('#todo_id_edit').val()){
$('Oh!laid-debe-ser-un-numero')。附加到($(“#更新结果”);
}否则{
getToToToEdit($('#todo_id_edit').val();
}
}))

$(“#按钮_保存_待办事项”)。单击(功能(e){
$(“#更新结果”)。文本(“”);
e、 预防默认值();
var todoEditado;
如果($('#id_to_edit').val()=''|$('#summary_to_edit').val()=''| |$('#todo_id_edit').val()=''){
$(“德比·雷勒纳尔·洛斯·坎波斯·ID y摘要。德比·坎波德·布斯克达·德比·康奈尔·洛斯·德比·德比·德尔·实际情况”)。附录($(“更新结果”);
}else if(isNaN($('#id_to_edit').val()){
$('La ID editada debe ser un numero')。附录($(“#update#u result”);
}否则{
todoEditado={
“id”:$(“#id_to_edit”).val(),
“日期”:$(“#date_to_edit”).val(),}
Editodo(todoEditado);
}});
如果有人能帮助确认这一天,我非常感谢

感谢JS中的

    function Datepicker() {
     this._curInst = null; // The current instance in use
      this._keyEvent = false; // If the last event was a key event
    this._disabledInputs = []; // List of date picker inputs that have been disabled
     this._datepickerShowing = false; // True if the popup picker is showing , false   
      if not
        this._inDialog = false; // True if showing within a "dialog", false if not
   this._mainDivId = "ui-datepicker-div"; // The ID of the main datepicker division
    this._inlineClass = "ui-datepicker-inline"; // The name of the inline marker class
   this._appendClass = "ui-datepicker-append"; // The name of the append marker class
   this._triggerClass = "ui-datepicker-trigger"; // The name of the trigger marker 
  class
   this._dialogClass = "ui-datepicker-dialog"; // The name of the dialog marker class
   this._disableClass = "ui-datepicker-disabled"; // The name of the disabled covering 
  marker class
   this._unselectableClass = "ui-datepicker-unselectable"; // The name of the 
   unselectable cell marker class
  this._currentClass = "ui-datepicker-current-day"; // The name of the current 
  day         marker class
  this._dayOverClass = "ui-datepicker-days-cell-over"; // The name of the day hover   
  marker class

 this.regional = []; // Available regional settings, indexed by language code
   this.regional[""] = { // Default regional settings
    closeText: "Done", // Display text for close link
    prevText: "Prev", // Display text for previous month link
    nextText: "Next", // Display text for next month link
    currentText: "Today", // Display text for current month link
    monthNames: ["January","February","March","April","May","June",
        "July","August","September","October","November","December"], // Names of   
  months for drop-down and formatting
    monthNamesShort: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", 
  "Oct", "Nov", "Dec"], // For formatting
    dayNames: ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday",   
 "Saturday"], // For formatting
    dayNamesShort: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], // For formatting
    dayNamesMin: ["Su","Mo","Tu","We","Th","Fr","Sa"], // Column headings for days 
  starting at Sunday
    weekHeader: "Wk", // Column header for week of the year
    dateFormat: "dd/mm/yy", // See format options on parseDate
    firstDay: 0, // The first day of the week, Sun = 0, Mon = 1, ...
    isRTL: false, // True if right-to-left language, false if left-to-right
    showMonthAfterYear: false, // True if the year select precedes month, false for 
   month then year
    yearSuffix: "" // Additional text to append to the year in the month headers
     };
使用


只需使用内置日期

function validate(str) {
  // Validate that str is in the format YYYY-MM-DDTHH:MM:SSZ.
  if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(str)) {
    return false;
  }

  // Validate that the values are also correct date values
  var d = new Date(str);

  return !isNaN(d.getTime());
}
moment().format('MMMM Do YYYY, h:mm:ss a'); // November 15th 2014, 11:34:04 pm
moment().format('dddd');                    // Saturday
moment().format("MMM Do YY");               // Nov 15th 14
moment().format('YYYY [escaped] YYYY');     // 2014 escaped 2014
moment().format();                          // 2014-11-15T23:34:04+03:30
function validate(str) {
  // Validate that str is in the format YYYY-MM-DDTHH:MM:SSZ.
  if(!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z$/.test(str)) {
    return false;
  }

  // Validate that the values are also correct date values
  var d = new Date(str);

  return !isNaN(d.getTime());
}