Just wanted to ask again if anyone has ever set up their php file called by the validator's remote method to return different error messages via JSON? I was hoping to see an example of how I might do this? Thanks so much.
Kim On Jan 7, 2:59 pm, Kim <mom2ma...@gmail.com> wrote: > Hi, > > I am fairly new to jquery, jqueryvalidationand competely new toJSON. I was > wondering if anyone could provide or point me to an > example of a use of the remote method of thevalidationplugin that > can display theerrormessagereturned by the remotely called php > file. > > I have an input field wherein someone enters an id to a database > table, specifically an id called media_id. I have the remote method > set up to call a php script (check_database.php) that looks for that > media_id in my database. There are a number of reasons that search > might fail: the id might not exist, or it might exist but have a > certain invalid status, etc. I would like to be able to display > amessagespecific to the problem rather than one generic "That id is > invalid"message. I read that my php script could return ajson > formattedmessage, but I am not sure how to do that, or how to modify > the javascript to handle what it gets back. I would appreciate any > help! > > my starting point in my javascript file: > > rules: { > media_id: { > required: true, > remote: 'check_database.php' > } > }, > > summary of what I am trying to do in check_database.php: > > database query with media_id > if no errors > return "true" > else if error1 > return ??? > else iferror2 > return ??? > etc.