SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    May 2012
    0 Post(s)
    0 Thread(s)

    PDF/Javascript - validation in a custom field.

    I have a series of text fields in a PDF: Month1, Day1, Year1.

    They all have a format category of custom, so I can run a keystroke script allowing me to autotab ...// For Month1 is would be: AutoTab(this, event, "Day1");

    Because it is set to CUSTOM and not NUMBER, I can not easily plug in the validation info (1-12 for Month, 1-31 for day, and a minimim of 2010 for the year). As I am a graphic designer, and not a programmer, I have no idea what code I would use in the custom validate box. I am guessing it would be 3 different snippets.. one for the day, one for the month, and one for the year.

    If you are able to assist me with the code to provide this functionality, I (and my boss) will be greatful!

    If you need additional information, please let me know. (I can post the PDF on a filehosting site if that will help you troubleshoot)


  2. #2
    SitePoint Enthusiast OMGCarlos's Avatar
    Join Date
    Apr 2012
    Boston, MA
    1 Post(s)
    0 Thread(s)
    I'd need to know a little bit more before I could help you. What if any code have you used? if I could see the PDF that would also be helpful.

    Based on what you've said you would need to do something like (event is the object that you put the javascript into):

    //First check that it is a number...
    	//...then check that it falls within x, y
    	if(event.value >= x and event.value <= y){
    	} else {
    		//** NOT WITHIN RANGE **//
    } else {
    	//** NOT A NUMBER **//
    //This function will check if n is a number
    function isNumber(n) {
      return !isNaN(parseFloat(n)) && isFinite(n);


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts