10 sie 2010

Sprawdzenie czy string ma format godziny

Kod javascript:

function test() {
  let czas = '12:14:38';
  let re = new RegExp('([0-9]{2})\:([0-9]{2})\:([0-9]{2})','ig');
  tmp=re.exec(czas);
  if(tmp!=null) {
    let obiekt_property = '';
    for(j in tmp) obiekt_property += j + ' '+ tmp[j] + '';
    alert(obiekt_property);
  }
}

html:

<body onload="test()"></body>
29 lip 2010

Ustawienie koloru tesktu pola input w zdarzeniu blur

<input type="text" id="from" value="Ciechanów" onblur="inp_blur(this)"/></p>
function inp_blur(field){
 if (field.value == ''){
  field.value = field.defaultValue;
  field.style.color='#93999e';
 }else{
  field.style.color='#000';
 }
}