validate form
by slawe
HTML
<textarea id="textareaID"></textarea>
<input type="text" id="yt_up_title" name="title" placeholder="Title...">
<span id="path_error"></span>
<br />
<input type="button" name="upload_video" id="submit" value="Upload" disabled="disabled">
JavaScript
var validatePath = function() {
var path = document.getElementById('yt_up_title').value;
var submitButton = document.getElementById('submit');
//document.getElementById('path_error').innerHTML='';
submitButton.removeAttribute('disabled');
if (path === ''){
//document.getElementById('path_error').innerHTML="Invalid Server Path!";
submitButton.setAttribute('disabled', 'disabled');
}
else{
var host_name = path.split(":")[0]
var regex = new RegExp("^[a-zA-Z0-9.]*$");
if(!(regex.test(host_name))){
document.getElementById('path_error').innerHTML="Invalid Server Path!";
submitButton.setAttribute('disabled', 'disabled');
}
}
}
document.onkeypress=validatePath;