I have a input field where users can write a domain name that they wish for search for.
My domain search only support searches as: "something.com" or "something"
And it only support .com, .net, .org
That I want to do is validate the user input before the ajax call is made and display an error message if anything is wrong. Example if a user types: "asdasdasd.asdasd" or "wwwasd.asdasd" or "www.asdasd.dk"
#domainsearch is the input field
#domanerknap is the search button
Here is my Jquery:
$(document).ready(function() {
$('#domanerknap').click(function(e) {
var doma = $('#domainsearch').val();
$('#contentajax').empty()
.css("border", "1px solid #CCCCCC")
.html('<p class="vent">Please wait...</p><p class="venter"><img src="../images/ajax.gif" /></p>');
$.ajax({
type: 'POST',
url: 'http://localhost:3000/domain',
data: {
domain: doma
},
success: function(msg){
$('#contentajax').html(msg);
$('#contentajax').css("border", "none");
}
});
});
});