Country code validation
parent
a3c4c54b83
commit
8a5f9c02c6
10
add.php
10
add.php
|
@ -8,11 +8,19 @@
|
||||||
Slika link:
|
Slika link:
|
||||||
</label><br />
|
</label><br />
|
||||||
<input type="text" id="emailField" name="slika"/> <br />
|
<input type="text" id="emailField" name="slika"/> <br />
|
||||||
|
<label >
|
||||||
|
Country code:
|
||||||
|
</label><br />
|
||||||
|
<input type="text" id="ccode" name="countryCode" onblur="validateCountry(this)"/> <br />
|
||||||
|
<label >
|
||||||
|
Broj telefona:
|
||||||
|
</label><br />
|
||||||
|
<input type="text" id="brtel" name="phoneNumber" onblur="validatePhone(this)"/> <br />
|
||||||
<label >
|
<label >
|
||||||
Tekst:
|
Tekst:
|
||||||
</label><br />
|
</label><br />
|
||||||
<textarea type="text" rows="30" cols="70" id="passwordField" name="vijest" ></textarea><br />
|
<textarea type="text" rows="30" cols="70" id="passwordField" name="vijest" ></textarea><br />
|
||||||
<input type="submit" name="submit" value="Submit" />
|
<input id="input" type="submit" disabled="true" name="submit" value="Submit" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</BODY>
|
</BODY>
|
||||||
|
|
1
gori.php
1
gori.php
|
@ -27,7 +27,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
print_r($slike);
|
|
||||||
$time = date(DATE_ISO8601, strtotime("now"));
|
$time = date(DATE_ISO8601, strtotime("now"));
|
||||||
$vijestiFile = $time.','.$slike.','.$vijest."\n".$vijestiFile;
|
$vijestiFile = $time.','.$slike.','.$vijest."\n".$vijestiFile;
|
||||||
$vijestiFile = strip_tags($vijestiFile);
|
$vijestiFile = strip_tags($vijestiFile);
|
||||||
|
|
|
@ -84,6 +84,12 @@
|
||||||
<option value="monthly">Novosti ovaj mjesec</option>
|
<option value="monthly">Novosti ovaj mjesec</option>
|
||||||
</select>
|
</select>
|
||||||
</li>
|
</li>
|
||||||
|
<li class="headerItem">
|
||||||
|
<select id="sort" name="sort" onchange="onSort(this.value)">>
|
||||||
|
<option value="date">Sortiraj po datumu</option>
|
||||||
|
<option value="alpha">Sortiraj abecedno</option>
|
||||||
|
</select>
|
||||||
|
</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
37
js.js
37
js.js
|
@ -89,6 +89,43 @@ function onFilter(select) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function validateCountry(countryCodeField) {
|
||||||
|
var ajax = new XMLHttpRequest();
|
||||||
|
ajax.onreadystatechange = function() {
|
||||||
|
if(ajax.readyState == 4 && ajax.status == 200) {
|
||||||
|
var nekiResponseObjekatNesto = JSON.parse(ajax.response);
|
||||||
|
var nizko = [];
|
||||||
|
for(var i = 0; i < nekiResponseObjekatNesto.length; i++) {
|
||||||
|
nizko.push(nekiResponseObjekatNesto[i].callingCodes);
|
||||||
|
}
|
||||||
|
document.getElementById("brtel").data = nizko;
|
||||||
|
validatePhone(document.getElementById("brtel"));
|
||||||
|
} else if (ajax.readyState == 4) {
|
||||||
|
document.getElementById("brtel").style.backgroundColor = "red";
|
||||||
|
document.getElementById("input").disabled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ajax.open("GET", "https://restcountries.eu/rest/v1/alpha?codes=" + countryCodeField.value, true);
|
||||||
|
ajax.send();
|
||||||
|
}
|
||||||
|
|
||||||
|
function validatePhone(phoneField) {
|
||||||
|
var nizko = phoneField.data;
|
||||||
|
console.log(nizko);
|
||||||
|
if(!nizko) return;
|
||||||
|
for(var i = 0; i < nizko.length; i++) {
|
||||||
|
console.log(phoneField.value.indexOf(nizko[i]));
|
||||||
|
var index = phoneField.value.indexOf(nizko[i]);
|
||||||
|
if(index == 0 || index == 1) {
|
||||||
|
phoneField.style.backgroundColor = "white";
|
||||||
|
document.getElementById("input").disabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
phoneField.style.backgroundColor = "red";
|
||||||
|
document.getElementById("input").disabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
function validateEmail(emailField) {
|
function validateEmail(emailField) {
|
||||||
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
||||||
if(re.test(emailField.value)) {
|
if(re.test(emailField.value)) {
|
||||||
|
|
|
@ -0,0 +1,2 @@
|
||||||
|
2016-05-22T18:53:53+0200,,hljebovi
|
||||||
|
2016-05-22T18:52:02+0200,+38761553000,Kemicin telefon se nigdje u bazi ne spasava
|
|
Loading…
Reference in New Issue