sigma19
asked on
jquery form
I have a html form:
==
<form onsubmit="return false;">
<input type="text" name="phone" size="20">
<input type="button" value="Phone">
</form>
===
I want to send the value user provided to a function.
$(document).ready(function () {
alert($("$fieldId").valida te());
});
==
Can you please provide me the syntex I should have to send the value from that form invoke
alert($("$fieldId").valida te());?
Also I want to get the value from that validate function to be send back to the forum
validate is a Jquery plug in (user defined)
==
<form onsubmit="return false;">
<input type="text" name="phone" size="20">
<input type="button" value="Phone">
</form>
===
I want to send the value user provided to a function.
$(document).ready(function
alert($("$fieldId").valida
});
==
Can you please provide me the syntex I should have to send the value from that form invoke
alert($("$fieldId").valida
Also I want to get the value from that validate function to be send back to the forum
validate is a Jquery plug in (user defined)
ASKER
Hi,
As you helped me in the other post:
https://www.experts-exchange.com/questions/27291256/jquery-plug-in.html
I want to incorporate this to a form.
The Form should have a submit button.
when I submit that , the plug in should be called to validate it.
I was able to get it working with out the form.
But when I insert the form, I am having issue in passing the value from Form to the validate function.
As you helped me in the other post:
https://www.experts-exchange.com/questions/27291256/jquery-plug-in.html
I want to incorporate this to a form.
The Form should have a submit button.
when I submit that , the plug in should be called to validate it.
I was able to get it working with out the form.
But when I insert the form, I am having issue in passing the value from Form to the validate function.
which is what i have suggested...Please try
ASKER
can you give me the syntax in the html page also
<html>
<head>
<title>Checker</title>
<head>
</head>
<body>
<script src ="http://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"> </script>
<script type ="text/javascript" src="sample.js"></script>
<script type ="text/javascript" src="extension.js"></script>
<form onsubmit="return false; id=form1">
<input type="text" name="phone" size="20">
<input type="button" value="Phone">
</form>
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks for the links.
Can you please tell me what I am missing.
On submit I am able to call the function I want.
But I am not able to pass the value from Form to function
Please point me to the exact way I can pass the values?
Can you please tell me what I am missing.
On submit I am able to call the function I want.
But I am not able to pass the value from Form to function
Please point me to the exact way I can pass the values?
<form id="form1" method="" action="">
<input id="phone" type="text" name="phone" size="20">
<input class="submit" type="submit" value="submit"/>
</form>
$(document).ready(function() {
$("#form1").submit(function() {
//$("#form1").val("123456");
alert($("#phone").validate1());
});
});
(function($){
$.fn.validate1 = function() {
// var str = $(this).val();
var str = '454550987111';
var re = new RegExp("^[0-9]{3}[\- ]?[0-9]{2}[\- ]?[0-9]{4}$", "g");
var myArray = str.match(re);
alert(str);
if ( myArray != null)
{
alert("hi");
return true;
}
alert("no");
return false;
};
if you are talking about how to pass the value of the field to validate method, then uncomment line 4 and comment line 5
Not sure that you meant
$(document).ready(function
$("#form1").submit(functio
$("#txt1").val("123456");
$("#form1").validate({
rules: {
txt1: {
maxlength: 5
}
}
});
});
});