|
|
|||||||||
|
|||||||||
|
|||||||||
| |
||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Javascript Generic Form validation
I have to implement a library of generic form validation tools, using Javascript, as described below.
isFieldFilledOut(field) Function takes one argument, generally a submitted form field, and returns true if the field has a real value (not NULL, EMPTY or “”) and false otherwise. doFieldsMatch(fieldOne, fieldTwo) Function takes two arguments, generally two submitted form fields - e.g. doFieldsMatch(Request.Form(“password”), Request.Form(“passConfirm”)) – and returns true if they are equal and false otherwise. isFormFilledOut(HTTPMethod) Function takes one argument defining the HTTP method used (GET or POST). Function chooses the appropriate ASP Request collection based on the argument, and loops through all submitted name=value pairs validating that all items have a real value (not NULL, EMPTY or “”) Return true if the form is filled out, return false otherwise. isEmailAddress(field) Function takes one argument, generally a submitted form field, and returns true if the field has a value valid for an internet email address and false otherwise. A valid email address: • begins with one or more letters, numbers, underscores, hyphens or periods (full stops) • contains exactly one at-sign (@) after that • continues with one or more letters, numbers, underscores, hyphens or periods (full stops) • ends with a period (full stop) followed by 2 or 3 letters. You can use pattern matching (regular expressions) or String methods to implement this function. fixURL(field) Function takes one argument, generally a submitted form field, and corrects it to ensure it is a valid web URL. Function returns the fixed URL. • If the first seven characters are not “http://” add those characters to the start of the string. • Escape the string for URL encoding (use built in methods from your chosen programming language) Any ideas as to how I would go about this? Thanks in advance. s |
|
#2
|
||||
|
||||
|
Smells like homework.
|
|
#3
|
||||
|
||||
|
Maybe you can get some ideas from here:
Javascript Field Validations -- Client Side Scripting by Nannette Thacker - 8/19/1999 http://www.shiningstar.net/articles...tions.asp?ID=AW Form Validation Using Javascript - 9/19/1998 http://www.4guysfromrolla.com/webtech/091998-1.shtml Good tips such as saving JavaScript functions in a file called DataValidation.js and including this in pages that need this. JavaScript functions. WebDaily: Your daily source for Web Technology Tips and Tricks! - 10/27/1998 http://www.4guysfromrolla.com/webtech/102798-1.shtml Just checks if fields filled in. Form Validation Scripts http://www.coolnerds.com/jscript/formval.htm
__________________
J. Paul Schmidt www.Bullschmidt.com - Freelance Web and Database Developer www.Bullschmidt.com/DevTip.asp - Classic ASP Design Tips |
![]() |
| Viewing: ASP Free Forums > Programming > HTML, JavaScript And CSS Help > Javascript Generic Form validation |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|