views:

22

answers:

3

Can someone look at this code. I am using two plugins in the form. One to validate form fields and other to style form fields.

Form validation validates form if I am comment out form styling code. ( // $('.ul').jqf1(); ) I want both of the plugins work together.

<link href="css/jqf1.css" rel="stylesheet" type="text/css" />
<script src="js/jquery.js"></script>
<script type="text/javascript" src="js/jqf1.english.js"></script>
<script src="js/jquery.validate.js"></script>
<script type="text/javascript">
$(document).ready(function(){
  $('.ul').jqf1();
$("#priceform").validate({
      rules: {
    email: {
      email: true,
      required: false
    },
    wordcount: {
     required: true,
     number: true
    },
    prating: {
    number: true
    }
  }
});});
</script>


<form action="" method="post" id="priceform">

<ul class="ul">
    <li><label for="Name">Name:</label></li><br/>
    <li><input type="text" id="name" size="20" name="name" maxlength="100" style="width:250px;" /></li>
</ul>

<ul class="ul">
    <li><label for="Email">Email:</label></li><br/>
    <li><input type="text" id="email" size="20" name="email" class="required" maxlength="20" style="width:250px;"/></li>
</ul>

<ul class="ul">
    <li><label for="username">UserName: <span class="optional">(Optional)</span></label></li><br/>
    <li><input type="text" id="username" size="20" name="username" maxlength="20" style="width:250px;"/></li>
</ul>

<ul class="ul">
    <li><label for="wordcount">Paper Word Count:</label><br/><a href="#">Calculate Word Count</a></li>
    <li style="padding-left:12px;"><input type="text" id="wordcount" size="20" name="wordcount" maxlength="20" style="width:50px;"/><span class="cumpolsory">*</span></li>
    <li style="color:green"><label id="totalPrice">$1000</label></li>   
    <li><label style="font-weight: 500; font-size:10px; color: gray;" for="totalprice">(Total Price)</label></li>
</ul>

<ul class="ul">
    <li><label>Plagiarism Rating:</label><br/><a href="#">Free Assessment</a></li>
    <li style="padding-left:15px;"><input type="text" id="prating" size="20" name="prating" maxlength="20" style="width:50px;"/><label>%</label></li>
</ul>

<ul class="ul" style="border-bottom:none;">
    <li><input type="Submit" id="name" size="20" name="name" value="Reset" maxlength="20" style="font-weight:700" /></li>
    <li style="float:right;"><input type="Submit" id="name" size="20" name="name" value="Place Order" maxlength="20" style="font-weight:700" /></li>
</ul>
</form>
A: 

Did you add "label.error" css code in your css file to show the error code?

Winthan Aung
NO..where to add it?..no idea..can u explain a little more?
mysterious
<style>#priceform label.error { width: 400px; float: left; color: red; padding-left: 10px; position:absolute; left:300px; } </style> Please add this one in your coding.
Winthan Aung
When I check your code, your label error code is invisible due to css. So I define error class code as absolute position to show error code on the top layer.
Winthan Aung
Does that work for you? You can put in your HTML code or CSS code.
Winthan Aung
A: 

try: 1. move the styling call to after the validation.

or

  1. force some action such as an alert after the styling to make sure that script didn't bomb out quietly before the validation assignment takes place.
FatherStorm
i did both of suggested things already..no use..so far as i can think styling call changes the name, ids, class names of tags..how about calling javascript function explicitly. Let me try.
mysterious
+1  A: 

This URL (http://www.webreference.com/programming/javascript/jquery/form_validation/) is the reference for you.

You can try to put this one to see how it responds in the page.

< style type="text/css"> #priceform label.error { width: 250px; display: block; float: left; color: red; padding-left: 10px; } < /style>

Winthan Aung
thanks..now i can see the error..let me fix its position now..any suggestion?
mysterious
<style> #priceform label.error { width: 400px; float: left; color: red; padding-left: 10px; position:absolute; left:300px; } </style> Please add this one in your coding. it will work perfect for your position.
Winthan Aung