sharon5467
-
Posts
3 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Posts posted by sharon5467
-
-
Many thanks for that, its a great help.Sharon
-
Hi I am trying to use create a validation form where I have a text box that the user has to enter two letters before digits, how can this be accomplished?Please help!!!Many Thanks
Validating using RegExp on Form
in JavaScript
Posted
HiI am trying to create the below form without much success. Please can anyone provide any tips or pointers of what I am doing wrong?<html><head><title>Untitled Document</title><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><script LANGUAGE="JavaScript" type="text/javascript"><!-- hide javascript codevar justValidating = truefunction validateForm(form) //validate assessment data { if (!validateStudentNumber(form.studentNum.value)) // student number valid? { form.studentNum.focus() return false }if (justValidating) // only show alert box if validating, and not submitting alert("Well Done: Your data is valid!") // all data validated return true }function validateStudentNumber(studentNum) { var myRegexp = /^[A-Z]{2}\d{7}/ if(myRegexp.test(/^[A-Z]{2}\d{7}/)) } alert("Please enter two letters before seven digits!") return false } return true }// end javascript hide --></SCRIPT></head><BODY BGCOLOR="white" TEXT="blue" onLoad="window.defaultStatus='JavaScript Assessment Frame'"><CENTER><H2>JavaScript Assessment</H2> <FORM NAME="assessForm" METHOD="post" ACTION="mailto:skinton11@yahoo.co.uk" onSubmit="justValidating=false; return validateForm(assessForm)"> Student Number: <INPUT NAME="studentNum" TYPE="text" SIZE="12" maxlength="9"> <INPUT TYPE="submit" VALUE="Submit"> <INPUT TYPE="button" VALUE="Validate" onClick="justValidating=true; validateForm(this.form)"> <INPUT TYPE="reset" VALUE="Reset"></FORM></body></html>Anyone have any suggestions??Many ThanksSharon