Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Validate form on submit
Message
 
To
24/09/2003 14:06:28
General information
Forum:
Internet
Category:
VBScript
Miscellaneous
Thread ID:
00831929
Message ID:
00831957
Views:
17
>Hi...... May I know how to implement a client side vb script form validation before submiting to server side. I try to use onSubmit, however how to control such as if it is invalid data then we stop submitting and show the user msgbox. Please guide.
>
>Thanks

My suggestion is to do this at the object level and Save level as well. I use a command button to call the Save Method

For Numeric:
sub txtTotalOK1_Onblur()
	if len(frmQPRDetail.txtTotalOK1.value) > 0 then
		if not IsNumeric(frmQPRDetail.txtTotalOK1.value) then
			alert ("Not a valid number")
			frmQPRDetail.txtTotalOK1.focus
		end if
		
		if frmQPRDetail.txtTotalOK1.value > 0 then
			if len(frmQPRDetail.txtPartNumberColor1.Value) = 0 then
				alert ("Part Number Required")
				frmQPRDetail.txtPartNumberColor1.focus	
			end if 	
		end if
	end if
end sub
For dates:
sub txtMfgDate_OnBlur()
	if len(frmQPRDetail.txtMfgDate.value) > 0 then
		if not IsDate(frmQPRDetail.txtMfgDate.value) then
			alert ("Not a valid date")
			frmQPRDetail.txtMfgDate.focus
		end if
	end if
end sub
In the Save Method:
Sub cmdSave_OnClick()
' I have a great deal of code for validation in this area...

if len(trim(frmQPRDetail.txtPartNumber.value)) < 12 then
		alert ("Enter 12 digits with no dash")
		frmQPRDetail.txtPartNumber.focus
		Exit Sub
end if

' If all is well...
call frmQPRDetail.Submit

End sub
Tom
Previous
Reply
Map
View

Click here to load this message in the networking platform