rivkamak
asked on
form submission verification on jquery mobile
I have a mobile jquery form. ON submission I check for verification and return false.
It's not stopping the form and I think it has to do with jquery mobile.
How am I supposed to get around it?
It's not stopping the form and I think it has to do with jquery mobile.
How am I supposed to get around it?
<form action="<%=MM_editAction%>" method="post" name="FrontPage_Form1" id="FrontPage_Form1" data-ajax="false" onSubmit="return FrontPage_Form1_Validator(this)">
<input type="submit" name="button" id="button" value="Submit" class="btnplaceOrder" /></form>
Verification looks like this: if (theForm.ccf_FirstName.value == "") {
alert("Please enter a value for the \"First Name\" field.");
$("#accordion").accordion( "option", "active", 1 );
theForm.ccf_FirstName.focus();
return (false);
}
Perhaps post the HTML for the field and include the function statement
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I strongly recommend never to use onclick of submit buttons.
The problem lies elsewhere
The problem lies elsewhere
Hi,
@mplungjan -
Yeah! I just created a sampe for the author to test. Anyway thanks for highlighting it!!!
@Author
Can you show the complete code to find the culprit.
Moreover, you are using "theForm.ccf_FirstName" , but the form ID is FrontPage_Form1 according to your form tag!
@mplungjan -
Yeah! I just created a sampe for the author to test. Anyway thanks for highlighting it!!!
@Author
Can you show the complete code to find the culprit.
Moreover, you are using "theForm.ccf_FirstName" , but the form ID is FrontPage_Form1 according to your form tag!
That is because the validation passes the form as theForm
function FrontPage_Form1_Validator( theForm) {
.
.
.
function FrontPage_Form1_Validator(
.
.
.
Hi,
In that case, it's working fine for me -
Hope it helps u...
In that case, it's working fine for me -
<form action="sample.htm" onsubmit="return Validate(this);">
<input type="text" name="txt" id="txt" />
<input type="submit" value="Submit"/>
</form>
<script type="text/javascript">
function Validate(theForm) {
if (theForm.txt.value == "") {
//Your logic to display custom message
document.getElementById("txt").focus();
return false;
}
}
</script>
Hope it helps u...
Why would you mix DOM and form access. You already have the field. Also return true if ok.
function Validate(theForm) {
if (theForm.txt.value == "") {
//Your logic to display custom message
theForm.txt.focus();
return false;
}
return true;
}
There is obviously something else wrong with the page - no need to post similar code to what is already used...
function Validate(theForm) {
if (theForm.txt.value == "") {
//Your logic to display custom message
theForm.txt.focus();
return false;
}
return true;
}
There is obviously something else wrong with the page - no need to post similar code to what is already used...
@mplungjan
Aaaah yeah! I didn't noticied it.
@Author
You need to respond to fix this issue!!!
Aaaah yeah! I didn't noticied it.
@Author
You need to respond to fix this issue!!!
ASKER
That script you gave didn't work either.
Is there any connection with the fact that I am using ajax mobile that isn't making that mobile form work?
Is there any connection with the fact that I am using ajax mobile that isn't making that mobile form work?
Possibly. Hard to tell with the snippet you sent.
I suggest you debug it
you can use Web Inspector on iPhone for example
I suggest you debug it
you can use Web Inspector on iPhone for example
Hi,
Are you using any third party plugins? Moreover, try creating a simple page and do some validation and check whether it works.
That way you can narrow down the issue easily!
Hope it helps u...
Are you using any third party plugins? Moreover, try creating a simple page and do some validation and check whether it works.
That way you can narrow down the issue easily!
Hope it helps u...
ASKER
I made it a simple form with a simple function
function Validate() {
console.log("function running");
return false;
}
the console is logged , but it doesn't return false. the form still submits.
my button looks like this:
<input type="submit" name="button" id="button" value="Submit" class="btnplaceOrder" onclick="Validate();"/>
function Validate() {
console.log("function running");
return false;
}
the console is logged , but it doesn't return false. the form still submits.
my button looks like this:
<input type="submit" name="button" id="button" value="Submit" class="btnplaceOrder" onclick="Validate();"/>
you need to
Onclick="return Validate()"
But better to do that in onsubmit of the form tag
Onclick="return Validate()"
But better to do that in onsubmit of the form tag
hmm