Message # 1 | 1:32 PM
Email form Specific numeric Validation

Just hoping you can give me some pointers/help on validating email form inputs.
I'm guessing i need to use javascript (although the possibility seems to be available in html5), but havent got much experience of javascript.

I need to validate that a specific text field when entered is numeric between a certain range.

Added

OK i have got so far by myself but just have one issue left.
I have added the script to the form template:-

<script language="JavaScript1.2">
function checkreference(){
var regexp=/^([0-9]{6})$/ //regular expression
if (document.mform.f8.value.search(regexp)==-1) //if match failed
alert("Invalid Welcome Pack Reference")
}

The relevant field is :-

<tr><td>Welcome Pack Reference<font color="red">*</font>:</td><td><input type="text" name="f8" size="30" style="width:95%;" maxlength="6"> </td></tr>

The button has been changed to call the script onclick :-

<tr><td colspan="2" align="center"><br /><input type="submit" onClick="checkreference()" value="Submit Activation"></td></tr>

My problem is that when an invalid entry is made , the message is displayed but the email is still sent.
Please advise

Added (2013-02-04, 6:31 PM)
---------------------------------------------
Any help would be appreciated smile

Added (2013-02-15, 7:32 AM)
---------------------------------------------
I have got a little bit further with this by simply changing the checkreference script to be called upon leaving the field and hence the message gets displayed earlier and the user gets a chance to correct the field before clicking the submit button..

However, i still cant stop the user clicking the submit button and an email being sent with an invalid (non-corrected) reference
sad


Post edited by Loz - Saturday, 2013-02-02, 8:36 AM