Form - Validate Input - Dialog
by bizamajig
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/themes/base/jquery-ui.css">
<div id="dialog" title="Dialog Title" style="display:none">
<p>Dialog box text.....Dialog box text....Dialog box text</p>
</div>
<form name="myForm" id="myForm" action="http://www.bizamajig.com/postit.asp" method="POST">
<textarea id="text" name="textAreaData"></textarea>
</form>
<input type="button" id="submitButton" name="submit" value="send" />
JavaScript
$('#submitButton').click(function(){
findUrls();
});
function findUrls()
{
var text = document.getElementById("text").value;
var source = (text || '').toString();
var urlArray = [];
var url;
var matchArray;
// Regular expression to find FTP, HTTP(S) and email URLs.
var regexToken = /\b(http|https)?(:\/\/)?(\S*)\.(\w{2,4})\b/ig; // this regex will match something like: asdf://sdaf.com
// Iterate through any URLs in the text.
if( (regexToken.exec( source )) !== null )
{
show_box();// this will show jquery dialog..
}
}
function show_box(){
$( "#dialog" ).dialog({
autoOpen: false,
width: 400,
buttons: [
{
text: "Yes",
click: function() {
$('#myForm').submit();
}
},
{
text: "No",
click: function() {
$( this ).dialog( "close" );
}
},
{
text: "Cancel",
click: function() {
$( this ).dialog( "close" );
}
}
]
});
$( "#dialog" ).dialog( "open" );
}