-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
67 lines (57 loc) · 1.57 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<style type="text/css">
#form{
padding: 10px;
}
#form label{
width: 150px;
color: blue;
float: left;
}
#form input {
margin: 2px;
}
#frmCvrlive{
color: red;
font-size: 14px;
font-weight: bold;
padding: 10px;
width:500px !important
}
</style>
<div id="form">
<label>CVR</label><input type="text" id="frmCVR"><br>
<label>Result</label>
<span id="frmCvrlive" ></span>
<textarea cols='60' rows='8' id="cvr_respons">Result...</textarea>
</div>
<script type="text/javascript">
jQuery( document ).ready(function() {
jQuery("#frmCVR").blur(function(e) {
var cvr = jQuery("#frmCVR").val();
var reg = new RegExp("^[0-9]{8}$");
if(!reg.test(cvr))
{
$('#frmCvrlive').show();
$('#cvr_respons').hide();
$('#frmCvrlive').html('angiv et gyldigt CVR-nummer');
}
else
{
$('#frmCvrlive').hide();
jQuery.getJSON("http://cvrapi.dk/api?search="+cvr+"&country=dk", function(data){
$('#cvr_respons').show();
// to fetch specif data
//console.log('companyName:'+data.name+' '+'Phone:'+data.phone+' '+'Email:'+data.email+' '+'zipCode:'+data.zipcode+' '+'Adreess:'+data.address);
$.each(data, function( index, value ) {
$('#cvr_respons').append(" "+index + ": " + value);
});
}).fail(function(jqXHR, textStatus, errorThrown) {
$('#frmCvrlive').show();
$('#cvr_respons').hide();
$('#frmCvrlive').html('angiv et gyldigt CVR-nummer');
})
}
});
});
</script>