fareedreg Posted January 12, 2010 Share Posted January 12, 2010 How can i make this script external and call it on my submit button <script type="text/javascript"> <!-- function validateDate(fld) { var RegExPattern = /^((((0?[1-9]|[12]\d|3[01])[\.\-\/](0?[13578]|1[02])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|[12]\d|30)[\.\-\/](0?[13456789]|1[012])[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|((0?[1-9]|1\d|2[0-8])[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?\d{2}))|(29[\.\-\/]0?2[\.\-\/]((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00)))|(((0[1-9]|[12]\d|3[01])(0[13578]|1[02])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|[12]\d|30)(0[13456789]|1[012])((1[6-9]|[2-9]\d)?\d{2}))|((0[1-9]|1\d|2[0-8])02((1[6-9]|[2-9]\d)?\d{2}))|(2902((1[6-9]|[2-9]\d)?(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)|00))))$/; var errorMessage = 'Please enter valid date as month, day, and four digit year.\nYou may use a slash, hyphen or period to separate the values.\nThe date must be a real date. 30/2/2000 would not be accepted.\nFormay dd/mm/yyyy.'; if ((fld.value.match(RegExPattern)) && (fld.value!='')) { alert('Date is OK'); } else { alert(errorMessage); fld.focus(); } } //--> </script> Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted January 12, 2010 Share Posted January 12, 2010 you would be looking at ajax... suggest you look at using jquery to help you here - its easy to learn and very powerful - puts the fun in javascript development. jquery Quote Link to comment Share on other sites More sharing options...
trq Posted January 12, 2010 Share Posted January 12, 2010 Doesn't have anything to do with ajax. Just remove the <script> tags, put it within a *.js file, source the file using.... <script src="nameoffile.js"> Then call it however you like. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted January 13, 2010 Share Posted January 13, 2010 ooops my bad - did read that properly - thought he wanted to call a php script... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.