Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
I have a webform with four fields. Name, empno, date, reason.

Datas are inserting properly into the table. No issues with that.

Now I want to validate the form with two entries per month.

I'm clueless on how to approach this thing.

A user can only submit the form twice per month. Not more than that.

Any suggestions is highly appreciated.
Posted
Updated 29-Oct-15 23:58pm
v4
Comments
ZurdoDev 30-Oct-15 6:31am    
Just add in a validation routine where you do a select count(*) as Solution 1 is suggesting. Very easy to do.

1 solution

>I'm clueless on how to approach this thing.


Why can't you make something like

[EDITED]
SQL
SELECT count(*) FROM your_table WHERE Month(date) = Month(getdate())
AND YEAR(date) = YEAR(GetDate())


before you try to insert into the table?

You do insert only if your result is < 2.
 
Share this answer
 
v2
Comments
ZurdoDev 30-Oct-15 6:30am    
Make sure to add and YEAR(DATE) = YEAR(GetDate())
Leo Chapiro 30-Oct-15 6:42am    
@RyanDev, Sure, thank you, I've edited!
ZurdoDev 30-Oct-15 8:32am    
+5
Leo Chapiro 30-Oct-15 8:46am    
Thanks again! :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900