Jump to content
  • 0

restrict Date entered


ppbb123
 Share

Question

2 answers to this question

Recommended Posts

  • 0

You can try to insert the following script into the footer of the DataPage.

<script type="text/javascript"> 

function show_confirm()
{ 
var Current = "[@cbTimestamp*]"; //get the current date
      Submit_Date = document.getElementById("InsertRecordFieldName").value;  //select from calender 

//format the date for comparing
var regS = new RegExp("-","gi"); 
Current =Current .replace(regS,"/"); 
Submit_Date=Submit_Date.replace(regS,"/"); 
var Current1 =new Date(Date.parse(Current)); 
var Submit_Date1 =new Date(Date.parse(Submit_Date));

if (Current1 >= Submit_Date1)
{
 document.getElementById("caspioform").submit();
}
else
{
alert("Wrong Date. Escape Submitted.");
return false;
}
}

document.getElementById("caspioform").onsubmit=show_confirm;

</script>

"InsertRecordFieldName" is the Date field Name on the submission form.

Link to comment
Share on other sites

  • 0

Thank you so much. That helps me a lot. And I figured out the code to restrict number field.   

<script type="text/javascript"> 

function show_confirm()
{ 
//get the insert value
var numberField= document.getElementById("InsertRecordNumberField").value;  

//compare the range, if the number field is between 1 to 100, then submit, otherwise an error message pops up
if ( numberField >= 1 && numberField <= 100)
{
 document.getElementById("caspioform").submit();
}

else
{
alert("Wrong Data. Escape Submitted.");
return false;
}
}

document.getElementById("caspioform").onsubmit=show_confirm;

</script>
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...