Hi
I wish to check certain user input fields for data validity before the linked update report executes.
For example I have a date field that needs to be checked for valid dates. The JavaScript I hope to use is:
function checkdate(input){
var validformat=/^\d{2}\/\d{2}\/\d{4}$/ //Basic check for format validity
var returnval=false
if (!validformat.test(input.value))
alert("Invalid Date Format. Please correct and submit again.")
else{ //Detailed check for valid date ranges
var monthfield=input.value.split("/")[0]
var dayfield=input.value.split("/")[1]
var yearfield=input.value.split("/")[2]
var dayobj = new Date(yearfield, monthfield-1, dayfield)
if ((dayobj.getMonth()+1!=monthfield)||(dayobj.getDate()!=dayfield)||(dayobj.getFullYear()!=yearfield))
alert("Invalid Day, Month, or Year range detected. Please correct and submit again.")
else
returnval=true
}
if (returnval==false) input.select()
return returnval
}
I'm trying to check the date by using the following:
select 'dbr.editable', 7, 'sp_DBR_plot_bookdate_edit', 'inPL_ID=ID','inPL_Bookdate=Plot_BookDate','callbefore=checkdate';
The 'callbefore' event doesn't do anything.
Please can you give an example of how to call a JavaScript function?
I have added the JavaScript code using select 'dbr.javascript' as well as pasting into the 'JavaScript/Help' input box.
Many thanks
Jake