I am new to cakePHP, I have submit button in cakePHP
$ajax->submit( 'Submit', array( "update" => "gridbox_script", "url" => '/flots/comparaison_gridbox_update', "div"=>"button_submit", "loading" => "setIboxOpacity = setOpacity;showBG();showIndicator();" , "complete" => "hideBG();hideIndicator()" ) );
I would like to add one javascript validation, if the validation returns true then it should proceed for submission otherwise submission should be terminated.
The whole submission is calling through ajax and I was advised to use $ajax
to implement.
my javascript function:
var firstCompare = new Array();
fucntion myValidation(){
var otherCompare = new Array();
if(document.getElementById("file1").checked)
otherCompare.push('file1');
result = (otherCompare.length === _.intersection(otherCompare, firstCompare).length);
firstCompare = otherCompare;
return result;
}
Please help me.
use the for id and check on submit or click event of your button.
$(document).ready(function() {
$('#formId').on('submit', function() {
var val = your_function() //call the function and store the return value
if (val) {
//do the submission
} else {
//code in case of false
}
});
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.