У меня есть следующая страница ColdFusion (см. Ниже). У меня проверена проверка jQueryTools. Он отлично работает с традиционной кнопкой отправки, но мне нужно, чтобы она работала по ссылке href, отформатированной как кнопка (немного ниже в коде). Я не могу понять, как получить ссылку href, которая обычно отправляет форму, чтобы запустить действие, которое приведет к тому, что страница будет проверена. ПЕРЕД отправкой формы.Нужна помощь при попытке запуска сценария проверки jQueryTools без кнопки отправки
Мои навыки работы с Javascript, как представляется, очень просты. Любая помощь будет принята с благодарностью.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><cfoutput>Welcome to#application.settings.meta_title#</cfoutput></title>
<script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script>
<link rel="stylesheet" href="/common/ext/jQuerytools/form.css" type="text/css" media="all" />
<style>
/* error container */
#errors {
\t background-color: #163356;
\t color: #fff;
\t width: 400px;
\t padding: 20px;
\t margin: 5px auto;
\t display: none;
\t -moz-border-radius: 5px;
\t -webkit-border-radius: 5px;
}
/* title */
#errors h2 {
\t margin: -5px 0;
\t color: yellow;
}
</style>
</head>
<body onLoad="self.focus();">
<h1>Pre Incident Plans Editor</h1>
<!--- BEGIN MAIN CONTENT AREA --->
<div id="main">
<div id="leftcol">
<form action="" method="POST" name="form2" id="form2">
<label for="addr_street">Address<br>
<input type="text" name="addr_number" id="Street Number" value="" style="width:50px;display:inline" placeholder="Number" required >
<input type="text" name="addr_street" id="Street Name" value="" size="32" placeholder="Street Name" style="display:inline" required />
<span class="field_instructions">Provide the street address that will match the CAD information</span> </label>
<label for="occ_name">
Occupancy Name<br>
<input type="text" name="occ_name" value="" style="width:100%" placeholder="Occupancy Name"/>
<input type="submit" name="button" id="button" value="Submit" class="button green medium">
</form>
</div>
<div id="rightcol">
<div id="publishingcontrols">
<h2>Publishing Controls</h2>
<div align="center"> <a href="#" onclick="document.getElementById('form2').submit();" class="button green large">Save</a> </div>
<div id="errors">
<h2>Please fix these first</h2>
</div>
</div>
</div>
<script>
// adds an effect called "wall" to the validator
$.tools.validator.addEffect("wall", function(errors, event) {
\t // get the message wall
\t var wall = $(this.getConf().container).fadeIn();
\t // remove all existing messages
\t wall.find("p").remove();
\t // add new ones
\t $.each(errors, function(index, error) {
\t \t wall.append(
\t \t \t "<p><strong>" +error.input.attr("id")+ "</strong> " +error.messages[0]+ "</p>"
\t \t);
\t });
// the effect does nothing when all inputs are valid
}, function(inputs) {
});
// initialize validator with the new effect
$("#form2").validator({
effect: 'wall',
container: '#errors',
// do not validate inputs when they are edited
errorInputEvent: null
// custom form submission logic
}).submit(function(e) {
});
</script>
</body>
</html>
Это то, что я не совсем ясно, на. Куда он добавляется? – SiriusPhil
Добавьте это к функции, в которой вы хотите инициировать проверку – dm4web