modal box an validation script

54 views
Skip to first unread message

jozz

unread,
Mar 19, 2011, 5:27:09 AM3/19/11
to ModalBox
Hi all, thaks for your help in ModalBox groups.

I have a modalbox window that contains a php form with post method,
but before to do submit i have to validate the form with javascript
validation.
I think I found the way do PHP form submit + javascript validation on
ModalBox Windows. I've tested on FF & IE

1. launch modal window from parent php page
<a href="childwindow.php" title="Title"
onclick="Modalbox.show(this.href, {title: this.title}); return
false;">Launch ModalBox</a>

2. on child window, only use onclick event on the buttom that is going
to submit, important type="button".
I use a javascript function to validate the form (JSValidateFunction)
that return true or false.
So all is going to do is to put a condicional in onclick event to
validate or send data thru another ModalBox, that in my case is the
same child window.
<form id="formname" name= "formname" method="post"
action="childwindow.php" onsubmit="return false;" ENCTYPE="multipart/
form-data" >
...
<input name="OK" type="button" value="OK"
onClick="javascript:if(JSValidateFunction==true)
{Modalbox.show('childwindow.php', {title: 'Result', method: 'post',
params: Form.serialize('formname'),overlayClose: true }); return
false;}else{return false;}" >
Reply all
Reply to author
Forward
0 new messages